Skip to content

feat(api): employer-side interview scheduling — the loop closes - #561

Merged
thinkclay merged 1 commit into
mainfrom
claude/ats-scheduling
Aug 11, 2026
Merged

thinkclay merged 1 commit into
mainfrom
claude/ats-scheduling

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

First half of #540. The issue reads "wire the screen to the scheduling SDK resource" — but that resource has two methods, getLink and bookSlot, and both are the candidate's.

There was no employer half at all

/v1/scheduling exposes two token-addressed routes for viewing and booking a slot. Nothing in the system could create a slot or mint a link. So the office scheduling screen had nothing to call and rendered MOCK_ constants (#525).

The tables have existed since migration 307 and became reachable when 335 added the grants they were created without. Only the endpoints were missing — same shape as #527, where the candidate side existed and the employer side didn't.

Adds GET/POST for slots and links under /v1/employer/scheduling, authorised with resolveApplicationOrgAccess + PIPELINE_ROLES.

The link token is deliberately not accepted from the client — the column defaults to encode(gen_random_bytes(32), 'hex'), so the secret is generated in the database and can't be chosen or predicted.

The loop closes

Verified end to end against a live local API:

1. employer POSTs a slot   → status "proposed"
2. employer POSTs a link   → token generated by the DB
3. candidate GETs /v1/scheduling/{token}
                           → org "Unicorn", job "Senior Software Engineer", 1 slot
4. candidate POSTs .../book → booked
5. slot status             → "booked"

That flow has never been possible. The candidate half existed but nothing could produce what it consumes.

Access control checked rather than assumed:

candidate proposes a slot on their own application  → 403
candidate lists slots                               → 403
nonexistent application                             → 404, not 403
slot_end before slot_start                          → 400

What this deliberately doesn't cover

Calendar connections. core.calendar_connections stores access_token_encrypted / refresh_token_encrypted / provider_account_id for Google and Outlook — that's an OAuth integration, not a CRUD endpoint. The "Connect Google/Outlook" panel stays disabled and the screen keeps its sample-data label until that's real.

Availability windows are untouched too — configuration rather than the scheduling loop.

Client wiring needs SDK methods, which is a submodule change: next step.

81 backend tests, zero new typecheck errors in the new file. Test data cleaned up — slots, links and bookings all back to 0 rows.

🤖 Generated with Claude Code

`/v1/scheduling` is the candidate's half: two token-addressed routes for
viewing and booking a slot. There was no employer half at all — nothing in the
system could create a slot or mint a link — so the office scheduling screen had
nothing to call and rendered MOCK_ constants (#525).

#540 reads as "wire the screen to the scheduling SDK resource". That resource
has two methods, `getLink` and `bookSlot`, and both are the candidate's. The
tables have existed since migration 307 and became reachable when 335 added the
grants they were created without; only the endpoints were missing.

Adds GET/POST for interview slots and scheduling links under
/v1/employer/scheduling, authorised with resolveApplicationOrgAccess and
PIPELINE_ROLES, 404 before 403 so application ids cannot be probed.

The link token is deliberately not accepted from the client: the column
defaults to encode(gen_random_bytes(32), 'hex'), so the secret is generated in
the database and cannot be chosen or predicted by a caller.

## The loop closes

Verified against a live local API, end to end:

  1. employer POSTs a slot          -> status "proposed"
  2. employer POSTs a link          -> token generated by the DB
  3. candidate GETs /v1/scheduling/{token}
                                    -> org "Unicorn", job "Senior Software
                                       Engineer", 1 slot offered
  4. candidate POSTs .../book       -> booked
  5. slot status                    -> "booked"

That flow has never been possible before: the candidate half existed but
nothing could produce the slots and links it consumes.

Access control checked rather than assumed:

  candidate proposes a slot on their own application  -> 403
  candidate lists slots                               -> 403
  nonexistent application                             -> 404, not 403
  slot_end before slot_start                          -> 400

## Not covered

Calendar connections. core.calendar_connections stores
access_token_encrypted / refresh_token_encrypted / provider_account_id for
Google and Outlook — that is an OAuth integration, not a CRUD endpoint. The
"Connect Google/Outlook" panel stays disabled and the screen keeps its
sample-data label until that is real. Availability windows are similarly
untouched; they are configuration rather than the scheduling loop.

Client wiring needs SDK methods, which is a submodule change — next step.

Refs #540
@github-actions

Copy link
Copy Markdown
Contributor

📊 Performance Benchmark Results


@thinkclay
thinkclay merged commit 3aac09a into main Aug 11, 2026
11 of 12 checks passed
@thinkclay
thinkclay deleted the claude/ats-scheduling branch August 11, 2026 15:26
thinkclay added a commit to Scaffald/sdk that referenced this pull request Aug 11, 2026
The scheduling resource had only the candidate's two token-addressed
methods (getLink, bookSlot). There was no employer half at all, which is
why the office scheduling screen rendered MOCK_ constants — there was
nothing to call.

Adds listSlots / createSlot / listLinks / createLink against the
/v1/employer/scheduling routes (Scaffald/SaaS#561).

Two things worth noting:

- `application_id` is optional on the list calls. The office scheduling
  screen is organisation-wide — "Upcoming Interviews" spans every open
  application — so omitting it lists across every organisation the caller
  can act for. Appending `application_id=undefined` would 400 against the
  uuid schema, so the param is omitted rather than stringified; there is a
  test for exactly that.

- `EmployerInterviewSlot` / `EmployerSchedulingLink` are deliberately
  separate from the existing `SchedulingSlot` / `SchedulingLink`. Those are
  the candidate's redacted view behind a link token; these carry the
  application, organisation and lifecycle status the pipeline needs. Same
  concept, different projections — collapsing them would leak employer
  fields into the candidate type.

`createLink` takes no token: it is generated server-side, and a
client-chosen token would be a guessable-URL vulnerability.

6 tests, mutation-checked — reverting the envelope unwrap or the optional
param turns them red.
thinkclay added a commit that referenced this pull request Aug 11, 2026
Completes the client half of #540. The scheduling API landed in #561; this
is the SDK and the screen.

Backend change first: the two list routes now take `application_id` as
*optional*. #561 required it, which turned out to be the wrong shape — the
office scheduling screen is organisation-wide ("Upcoming Interviews" spans
every open application, as the mock it replaces did), so with no
application_id the routes list across every organisation the caller can
act for. A caller with no organisations gets an empty list rather than a
403; a personal account should see an empty schedule, not an error.

Screen:

- Slots and links come from `/v1/employer/scheduling`. Loading, error and
  empty states, none of which existed.
- Candidate names are resolved by joining the org's applications. The
  scheduling tables carry `application_id` and nothing about the person, so
  the name is looked up rather than denormalised.
- Both modals write. "Propose Time" and "Create Link" previously opened
  forms whose submit button only closed the modal, so a user could believe
  they had scheduled an interview with a candidate who would never hear
  about it. They now validate and POST, with the errors surfaced.
- Stat tiles derive from real slots. `no_show` is folded into completed —
  it exists in the database but not in this screen's union, and it is a
  finished interview, not an upcoming one.

Two bugs found while wiring:

- The link row rendered `schedule.scaffald.com/<token>`. That host does not
  exist; the real route is `/schedule/[token]`. A recruiter who copied that
  link sent a dead URL. Copy now yields a URL that resolves.
- Link status read `is_active` alone. That flag is the employer's kill
  switch, not the clock, so an expired link showed as "Active". Expiry is
  now checked too.

`USES_SAMPLE_DATA` narrowed to `CALENDAR_USES_SAMPLE_DATA` rather than
disappearing, and the notice moved from the whole screen onto the Calendar
Connections tab. Connections and availability are still placeholders, and
not because a CRUD endpoint is missing: `core.calendar_connections` stores
`access_token_encrypted` / `refresh_token_encrypted` /
`provider_account_id` for Google and Outlook, which is an OAuth
integration. Availability feeds slot generation, which does not exist
either. Those two write paths stay disabled. So #540 is done; the calendar
integration is not, and the label stays until it is.

Verification: the existing test file said to replace its sample-data
assertions with real ones rather than delete them, so it now has 12 tests
covering the transform, both write paths, the URL and the expiry logic.
Mutation-checked — dropping the no_show remap, judging links by is_active
alone, or restoring the fabricated host each turns a test red. 248 office
+ utils tests pass. The routes were also driven from a real browser
session: cross-origin preflight, auth and both list endpoints, returning
only the caller's organisation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant