Repository navigation
feat(applications): listForOrganization — the hiring-side pipeline - #13
Merged
Merged
Conversation
`list()` is the candidate's view: the REST handler behind it filters on `user_id = auth user`, so a recruiter calling it gets their own applications, which is normally none. There was no SDK method for reading the pipeline of an organisation you hire for, and consequently no way for the office kanban to show anything. Adds `client.applications.listForOrganization()` against `GET /v1/employer/applications`, with filters for organisation, job, stage, assignee, minimum score and a creation-date range. The response types mirror the database rather than the office UI's older assumptions: the score is `score_total`, and the flat screening fields live inside `screening_answers` rather than as columns. `EmployerApplication` carries only the candidate identity a pipeline card needs — not contact details. `min_score` is serialised on an `!== undefined` check rather than truthiness, so an explicit floor of 0 reaches the server instead of being silently dropped. There is a test for that specific case. Requires the corresponding endpoint in Scaffald/SaaS.
Every other applications type is re-exported from src/index.ts, so consumers importing from '@scaffald/sdk' rather than the resource subpath could name Application and ListApplicationsResponse but not EmployerApplication. Caught on review of the previous commit; exports.test.ts does not enforce completeness.
This was referenced Aug 5, 2026
thinkclay
added a commit
to Scaffald/SaaS
that referenced
this pull request
Aug 5, 2026
…nd truthful placeholder screens (#543) * docs(agents): triage audit findings to GitHub Issues, not markdown Audits and reviews were producing markdown plan docs under docs/plans/, which go stale in the repo and never get triaged off a board. Document the issue-first shape instead: survey for dupes, one issue per self-contained finding with file:line evidence, a rollup epic carrying the narrative and dependency graph, and milestones for the version plan. Design specs and architecture proposals stay as markdown — the rule is about findings, not intent. Reference example: the 2026-08-03 /office ATS audit, epic #539. Co-Authored-By: Claude Opus 5 <[email protected]> * style(compliance): format EEOReportScreen with biome This file has never satisfied `biome check` — the MOCK_JOB_GROUPS entries were written as long single-line object literals. Formatting it in its own commit so the behavioural change that follows stays readable; the diff here is 934 lines and none of it changes what renders. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(compliance): stop presenting fabricated EEO figures as a compliance record The EEO/OFCCP screen has no data hooks. MOCK_JOB_GROUPS, GENDER_SUMMARY and VETERAN_SUMMARY are hardcoded, and the four-fifths-rule adverse-impact analysis runs real math over those invented headcounts. Nothing on screen said so. An EEO report is an artifact people file, so a screenshot of this page would have circulated fabricated adverse-impact figures. Behind a single USES_SAMPLE_DATA flag that #535 deletes when real data lands: - Add a persistent, non-dismissible "Sample data — not a compliance record" notice above everything else. Not dismissible on purpose: the point is that it survives into a screenshot. - Hide the green "Compliance Status: Active / Next filing deadline" banner. That was an affirmative claim about compliance posture with nothing behind it — worse than the invented numbers. - Disable Export. Export is how fabricated figures stop being a screen and become a document someone might file. Also derives the "Adverse Impact — flags detected" tile from the computed ratios instead of hardcoding "0". It agreed with the ratios only by coincidence, and would have kept reading 0 after real data arrived. Tests assert the notice renders, the compliance claim is absent, and export is disabled. Verified they fail when USES_SAMPLE_DATA is flipped off. Refs #524 * style(scheduling): format CalendarSchedulingScreen with biome Same situation as EEOReportScreen: the file has never satisfied `biome check` because the MOCK_* entries are long single-line literals. Formatting in its own commit so the behavioural change that follows is readable. Nothing here changes what renders. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(ats): stop presenting disconnected interview scheduling as live The scheduling screen has no data hooks — MOCK_CONNECTIONS, MOCK_AVAILABILITY, MOCK_SLOTS and MOCK_LINKS are rendered directly, though migration 146 created core.interview_slots / interview_availability / interview_bookings and both an API route and an SDK resource already exist. The placeholder lists were the smaller half. The larger half is that every action is inert: "Propose Time" opens a full form whose submit button only calls setShowAddSlotModal(false). A user could fill it in, click through, and believe they had scheduled an interview with a candidate who will never hear about it. "Create Link", "Connect Google/Outlook", "Add Availability" and "Copy" are all no-op onPress handlers too. Behind a USES_SAMPLE_DATA flag that #540 deletes when the wiring lands: - Add the sample-data notice, stating plainly that nothing is saved and no candidate is contacted. - Disable every write action, so input is refused rather than silently discarded. Refusing is honest; accepting and dropping is not. - Derive the Upcoming/Confirmed/Completed tiles from the slot list. They were hardcoded "3" / "1" / "12"; the first two matched the mock by coincidence and "12 completed" was invented outright. Extracts SampleDataNotice into features/office/components now that a second screen needs it, and moves EEOReportScreen onto it. Each caller keeps its own USES_SAMPLE_DATA flag so deleting the flag is the last step of wiring that screen to real data. Tests assert the notice renders, every write action is disabled, and the tiles are derived. Verified the first two fail when the flag is flipped off. Refs #525 * fix(api): map application status to the DB vocabulary on write, not just read core.applications.status is TEXT constrained by applications_status_check (migration 112) to the DB vocabulary: new, screen, inquired, interview, offer, hired, rejected, withdrawn. The REST surface publishes a different one, where new is "pending" and screen is "reviewing". The read path translated via STATUS_API_TO_DB. The write path spread the validated body straight into .update(), so an API name reached the column: PATCH {status:"pending"} -> writes "pending" -> CHECK violation, 500 PATCH {status:"reviewing"} -> writes "reviewing" -> CHECK violation, 500 PATCH {status:"inquired"} -> 400, missing from the update schema enum the other five -> worked only because both vocabularies spell them identically Three of the office kanban's seven stages were unreachable by name, and the four that worked did so by luck. Confirmed against the local database: UPDATE ... SET status='pending' and 'reviewing' both raise check_violation, while 'new' and 'inquired' are accepted. - Extract buildApplicationUpdatePayload() and translate status through STATUS_API_TO_DB before writing. - Add `inquired` to applicationUpdateSchema. The SDK's Application union already declared it and the DB already accepted it; only the server schema disagreed, so the request never reached the handler. - Add withApiStatus() and use it on every response. POST, PATCH and withdraw all returned raw DB names while applicationResponseSchema declares the API enum — responses violating their own published contract. Read handlers did this inline; folded them into the helper too. - Type the kanban's STATUS_MAP against the SDK union so the call sites need no casts. The two casts had drifted: confirmChange omitted `inquired`, so the path handling critical hire/reject confirmations disagreed with the one that does not. 12 tests. The four covering buildApplicationUpdatePayload fail when it is reverted to the old spread; the rest guard the vocabulary invariants. Not addressed here: triggerWebhook still emits raw DB status names, so webhook consumers see `new` where the REST API says `pending`. Changing that is a breaking change for anyone already consuming them — filing separately. `deno check` on this file reports 75 errors before and after this change; they are all c.get() returning never, tracked in #477. Refs #529 * feat(api): employer-scoped applications read path Every handler on /v1/applications is the candidate's view — it filters or gates on `user_id === auth user`. A recruiter had no way to read the pipeline for their own organisation's jobs, which is why the office kanban has rendered zero rows since the tRPC→SDK migration. - Extract the access decision the two message handlers already got right into lib/application-access.ts, and put both of them on it. Behaviour there is unchanged by construction: they pass no role allow-list, which reproduces "any org-scoped assignment" exactly. - Add GET /v1/employer/applications: org-scoped list with candidate and job embedded, filtering by organization_id, job_id, status, assigned_to, min_score and a created_at range, with real pagination. - Admit the hiring side to GET /{id} and GET /{id}/activity, which previously 403'd anyone but the applicant. The activity log is where stage history lives, so a recruiter could not see it at all. On the role allow-list. The extracted block accepted *any* role_assignments row scoped to the org, with no role filter. Today that happens to mean "org admin", because admin is the only org-scoped role with assignments — but `member` exists in core.roles, and the day someone assigns it that check silently widens. Reading a thread you are party to is a narrow grant; listing every applicant's profile and screening answers is not. So the helper takes an explicit allow-list per call site: the message handlers keep the permissive behaviour, the pipeline endpoints pass PIPELINE_ROLES (admin only). If recruiters are meant to hold `member`, widening is one line at PIPELINE_ROLES — but that should be a decision rather than an inherited default. Column names here are the real ones. There is no `applied_at`, `application_score` or `auto_rejected` column on core.applications; scores are `score_total` and the flat screening fields live inside the `screening_answers` JSONB. The office transform assumes otherwise — reconciling it is #528. Every PostgREST select was validated against the live local database rather than by inspection, including the users!user_id and jobs!job_id embeds and the roles!role_id join the allow-list depends on. 24 tests. Verified the allow-list check is load-bearing by removing it and watching the member-vs-admin test go red; cross-org denial is a separate control with its own test, and survives that mutation as it should. `deno check` on applications.ts drops from 75 pre-existing errors to 69 — the inline access blocks were themselves untyped c.get() sites (#477). Refs #527 * feat(office): wire the ATS pipeline to real data Bumps @scaffald/sdk to c7c9884 (Scaffald/sdk#13, listForOrganization) and puts the office applications screen on it. The board has rendered zero rows since the tRPC→SDK migration because useApplications() returned a hardcoded [] with its filter argument discarded. - useApplications() now queries GET /v1/employer/applications and passes its filters through. ApplicationsListItem is the SDK's EmployerApplication rather than a hand-maintained restatement; the local interface had drifted to declare applied_at and application_score, neither of which is a column, and nothing caught it because the hook it typed always returned []. - Rewrite the transform against the real schema: score_total not application_score, created_at not applied_at, attachment_metadata not attachments, and screening_answers.* rather than flat columns. It was written against a v_applications_with_user_profiles view that exists in no migration. - Status, job and score filters now go to the server. The status filter was *cast* from the kanban vocabulary to the API's — which satisfied the compiler while sending a value the API enum rejects. It is mapped now, via the same STATUS_MAP the write path uses. - Drop the client-side score filter. With server pagination it would have been wrong rather than redundant, silently hiding matches beyond page one. Also fixes a bug the end-to-end check caught: min_score=0 returned none of the eight seeded applications. score_total is nullable and nothing populates it yet, so `.gte("score_total", 0)` drops every row — NULL >= 0 is NULL, not true. The board's slider defaults to 0, so opening the pipeline would have shown an empty board for a different reason than before. Extracted as shouldApplyScoreFilter() with tests. Verified against a live local API served from this worktree, since the running edge runtime serves a different one: an org admin gets 8 applications with candidate names and correctly mapped statuses; a candidate gets 0 rather than everyone's pipeline; requesting another org's id is 403, as is an unknown org id. Status, pagination and score filters all checked against real rows. Team assignment is left null rather than invented — it lives in core.job_team_assignments, which the list endpoint does not join yet. stageHistory/notes/messages stay empty for the same reason (#531). Refs #527, #528 * chore(office): route and navigation cleanup Six unrelated bits of routing debt found in the /office audit. - /office/ats rendered the applications pipeline, making it a second URL for /office/applications — the same screen behind two drawer entries. ATS is a section, not a screen, so its index now redirects and the duplicate drawer entry is gone. - /office/ats/metrics rendered the same screen on its default kanban view; its own comment said the user could "switch to Metrics tab". The screen now takes an initialView and the route passes 'metrics'. - ROUTES.OFFICE.ATS.DETAIL declared /office/ats/:id, which no file backed. Removed; a real detail route is #537. - office/_layout.tsx named jobs/, teams/, organizations/, universities/ and background-checks/ at the top level. Those moved under cms/ and ats/ some time ago, so every Stack.Screen entry was a silent no-op while the routes that do exist had none. Rewritten against the actual files, and checked in both directions: no name without a file, no file without a name. - ID Verifications, Hiring Metrics and Self-Schedule existed as routes but appeared in no navigation, so they were reachable only by typing the URL. Added to the office CMS nav. - Removed the "List" view toggle. It rendered "List view coming soon..." — a shipped nav control leading to a placeholder. #537 covers the real thing. Refs #526 * style(api): satisfy `deno fmt --check` across functions/api The "Lint REST API Code" job runs `deno fmt --check` and was already failing on main: routes/inquiries.ts, routes/work-logs.ts, __tests__/contract/sdk-routes and __tests__/routes/inquiries-by-application were all unformatted before this branch. Two more were mine — routes/employer-applications.ts and the new application-access test. Formatting all six rather than only my own, since `deno fmt` is mechanical and it takes the check from red to green instead of red-for-fewer-reasons. No behavioural change; the 27 backend tests pass unchanged. * chore(sdk): bump pointer to 09f0cad (lint fix for the employer list tests) Picks up Scaffald/sdk#14, which drops the non-null assertions the monorepo's biome config rejects but the SDK package's own lint does not. Deliberately NOT bumping to sdk main (e4a47e5). That tip includes sdk#12, which drops the phantom prerequisites endpoints and breaks scf-core typecheck in 17 places — prerequisites-sdk-hooks.ts and PrerequisiteWidget.tsx still use the removed types. The matching client changes live in #519, not here, so this branch pins to the commit before that break. Verified: scf-core typechecks clean at this pointer and fails at e4a47e5. --------- Co-authored-by: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
client.applications.listForOrganization(), the employer-side counterpart tolist().Why
list()is the candidate's view — the REST handler behind it filters onuser_id = auth user. A recruiter calling it gets their own job applications, which is normally none. There was no SDK method for reading the pipeline of an organisation you hire for, and consequently no way for the office kanban in Scaffald/SaaS to display anything. It has rendered zero rows since the tRPC→SDK migration.What
GET /v1/employer/applications, with filters for organisation, job, stage, assignee, minimum score and a creation-date range.Response types mirror the database rather than the office UI's older assumptions — the score is
score_total, and the flat screening fields live insidescreening_answersrather than as columns.EmployerApplicationcarries only the candidate identity a pipeline card needs, deliberately not contact details.Note on
min_scoreSerialised on
!== undefinedrather than truthiness, so an explicit floor of0reaches the server instead of being silently dropped. There is a test for exactly that case — it fails if the check is changed toif (params?.min_score).Testing
4 new tests, 781 pass overall. Verified the
min_score: 0guard is load-bearing by mutating the check and watching that test go red.Depends on
The
/v1/employer/applicationsendpoint in Scaffald/SaaS — see Scaffald/SaaS#527. Merge this after that endpoint lands, then bump the submodule pointer there.