Skip to content

fix(tests): drop non-null assertions from the listForOrganization tests - #14

Merged
thinkclay merged 1 commit into
mainfrom
fix/lint-non-null-assertions
Aug 5, 2026
Merged

thinkclay merged 1 commit into
mainfrom
fix/lint-non-null-assertions

Conversation

@thinkclay

Copy link
Copy Markdown
Contributor

Follow-up to #13.

The monorepo's root biome config enforces lint/style/noNonNullAssertion; this package's own pnpm lint does not. So 12 query!.get(...) calls passed locally and then failed the consumer's "Lint, typecheck & build" job in Scaffald/SaaS.

Initialising the captured params to an empty URLSearchParams removes the assertions without weakening the tests — each still asserts a positive value that only appears if the request actually went out.

Verified the tests still bite: reverting min_score serialisation to a truthiness check turns "sends min_score=0 rather than dropping it" red, same as before this change.

781 tests pass, typecheck clean.

The monorepo's root biome config enforces lint/style/noNonNullAssertion, which
this package's own `pnpm lint` does not, so 12 `query!.get(...)` calls passed
locally and failed the consumer's "Lint, typecheck & build" job.

Initialising the captured params to an empty URLSearchParams removes the
assertions without weakening the tests: each one still asserts a positive value
that only appears if the request actually went out, and the min_score=0 test
still fails when the serialisation is reverted to a truthiness check.
@thinkclay
thinkclay merged commit 09f0cad into main Aug 5, 2026
@thinkclay
thinkclay deleted the fix/lint-non-null-assertions branch August 5, 2026 19:51
thinkclay added a commit to Scaffald/SaaS that referenced this pull request Aug 5, 2026
…ests)

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.
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]>
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