You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[#649] Add Career job ingestion, dedupe and classification - #672
#633 ports CS Job Poster into Forge. Cron (#652 adapters, #653 polling) fetches raw listings; this PR adds the API side that turns each source's snapshot into deduplicated Job rows with locations, categories, an active/inactive lifecycle, and a silent first-run baseline. #651 search, #653 and #654 build on this data.
classify: decides track, and category using rules ported from upstream categories.py.
locations: parses city, state and U.S. remote, and detects foreign locations.
listing: prepares each listing and records why it was rejected.
Dedupe uses IDs only, strongest first:
an ATS requisition ID;
the cleaned apply URL, but only when it points at one posting (careers landing pages and aggregator links never count);
otherwise an ID scoped to the source.
Matching compares the hash column and also the raw key. Concurrent ingests of the same job produce one job.
Lifecycle:
A source's first successful run is silent.
After that, a new job is queued (pending) only when cron passes a channel for its track.
When a full inventory omits a job, it closes; a rolling feed never closes anything.
A reappearing job reopens without being posted again.
A snapshot fetched before a newer run closed a job can't reopen it.
Each listing is validated on its own, so one bad listing never blocks a board. Rejection reasons: invalid_listing, invalid_apply_url, not_student_role, non_us. Any U.S. signal keeps a location ("London, KY", "ON-SITE - Austin, TX").
Never creates Company rows. A job links to an approved Company by normalized name or alias.
No schema changes. Uses the 0065 tables as merged.
Known limit (documented in the SRD): when an aggregator listing creates a job first, a later employer listing of the same posting shares no ID with it, so the job is posted twice. Mitigations are proposed for #652 (send the employer link) and #654 (posting guard).
Test Plan
pnpm format, pnpm lint, pnpm typecheck: pass. The new integration test has one max-lines warning.
@forge/apipnpm test against local PostgreSQL 16: 151 files, 1256 tests pass. That includes the rule tests in tests/job-board/ingestion-rules.test.ts and the ingest tests in tests/integration/job-board-ingest.test.ts.
Ran forge-review (standard tier: api-shape, validation/placement and test-quality reviewers) and fixed what it found. I broke the code on purpose to check that the new stale-run and kept-details tests fail.
Test cases are listed in .forge/features/career-job-ingestion/test-cases.md (TC-001 to TC-026, NEG-001 to NEG-004).
Out of scope: polling, leases and error recording (#653); Discord sends (#654). Upstream's "recent catch-up" of first-run jobs is not ported, by decision.
Checklist
Database: No schema changes, OR I ran pnpm db:generate and committed the generated files in packages/db/drizzle/
Environment Variables: No environment variables changed, OR I have contacted the Development Lead to modify them on Coolify BEFORE merging.
The change adds snapshot and listing validation, identity normalization, track and category classification, U.S. location parsing, and job ingestion in @forge/api. The ingestion process supports source baselines, job matching, observation updates, and full-inventory closure. New unit and database integration tests cover these behaviors.
Merge Risk: Moderate · up to 0d732
The new job ingestion can merge distinct openings into one job when board keys contain colons or when shared careers links carry numeric query parameters. Overlapping full-inventory runs from different sources can leave closed jobs active. A few edge cases around conflict recovery, out-of-order snapshots and lowercase state codes also give wrong results. Fix the identity and closure issues before merge.
Pre-merge checks: 7
Check name
Status
Explanation
Title check
The title begins with the issue number in brackets, "[#649]", followed by a concise description of the main change, and is 58 characters, under the 72-character limit. It matches the requirements and …
Description check
The description explains the motivation (#633 port of CS Job Poster), lists the new schema, ingestion function, pure rules for normalization, classification, locations, and listing preparation, dedupe…
Linked Issues check
Only #649 is directly linked and active. Its coding requirements are met by the ingestion layer:
- Cron input contract: careerJobSourceSnapshotSchema in @forge/validators (`packages/validators/sr…
Out of Scope Changes check
Changed files map to #649 objectives or their supporting work:
- packages/validators/src/job-board.ts: snapshot contract. - packages/consts/src/job-board.ts: JOB_SOURCE_INVENTORIES for full ver…
No Hardcoded Secrets
No hardcoded secrets found in the 15 changed files. Searches of added lines covered key/secret/password/token patterns, vendor token prefixes (sk-, ghp_, xox, AKIA), PEM headers, credentialed URLs, an…
Validated Env Access
Checked the PR range refs/coderabbit/pre-merge-check/base..head. It changes 15 files. No added line in the diff contains process.env. A search of each changed file's head version also found no `proc…
No Typescript Escape Hatches
The check flags any types, @ts-ignore, @ts-expect-error, and non-null assertions (!.) in changed code. I took the PR diff against refs/coderabbit/pre-merge-check/base and scanned all added `…
Full details: Title check
Explanation
The title begins with the issue number in brackets, "[#649]", followed by a concise description of the main change, and is 58 characters, under the 72-character limit. It matches the requirements and the changeset, which adds career job ingestion, deduplication, and classification.
Full details: Description check
Explanation
The description explains the motivation (#633 port of CS Job Poster), lists the new schema, ingestion function, pure rules for normalization, classification, locations, and listing preparation, dedupe and lifecycle behavior, and the test plan. It directly matches the changeset.
Full details: Linked Issues check
Explanation
Only #649 is directly linked and active. Its coding requirements are met by the ingestion layer:
Cron input contract: careerJobSourceSnapshotSchema in @forge/validators (packages/validators/src/job-board.ts) and the spec and SRD documents in .forge/features/career-job-ingestion/.
Grouping and dedupe: normalize.ts builds identity keys (ATS requisition ID, cleaned apply URL, source-scoped ID). ingest.ts matches on hash and raw key. Integration tests cover dedupe and concurrent ingest.
Classification: classify.ts (category and track) and locations.ts (U.S. location parsing, foreign filtering).
First seen, last seen, and active state: ingest.ts maintains observations and deactivates jobs on full-inventory omission. Reopen and stale-snapshot rules are implemented and tested.
Silent baseline: the first successful run records a baseline and queues no Discord delivery. Covered by job-board-ingest.test.ts.
One point is not implemented in this PR. #649 states that inactive listings are "excluded from default search". The PR adds no search filter, and the PR description assigns search to #651. The data side (active flag) is present. Search exclusion is treated as out of this PR's scope.
Full details: Out of Scope Changes check
Explanation
Changed files map to #649 objectives or their supporting work:
packages/consts/src/job-board.ts: JOB_SOURCE_INVENTORIES for full versus rolling inventories.
packages/api/package.json and packages/api/src/job-board.server.ts: cron-only export of ingestJobSnapshot.
packages/api/src/utils/job-board/*: normalization, classification, location, listing preparation, and ingest.
packages/api/src/utils/career/us-cities.ts: findUsCity used by location parsing.
Tests under packages/api/src/tests/.
.forge/features/career-job-ingestion/*: spec, SRD, status, and test cases for the same feature.
No tRPC procedure, schema change, polling, or Discord send code is listed in the summary. Those items are excluded by the PR description.
Full details: No Hardcoded Secrets
Explanation
No hardcoded secrets found in the 15 changed files. Searches of added lines covered key/secret/password/token patterns, vendor token prefixes (sk-, ghp_, xox, AKIA), PEM headers, credentialed URLs, and long opaque literals. Every hit was benign: url.username || url.password is a guard that rejects credentialed URLs in normalize.ts; key in us-cities.ts is a cache lookup string; the 64-hex literal in the test is the published SHA-256 test vector for "abc". The integration test gets its database URL from provisionDisposableDatabase at runtime and stubs DATABASE_URL through vi.stubEnv, so no credential is committed.
Full details: Validated Env Access
Explanation
Checked the PR range refs/coderabbit/pre-merge-check/base..head. It changes 15 files. No added line in the diff contains process.env. A search of each changed file's head version also found no process.env reference. The new code adds no direct env access outside env.ts or .config. files, so the custom check is satisfied.
Full details: No Typescript Escape Hatches
Explanation
The check flags any types, @ts-ignore, @ts-expect-error, and non-null assertions (!.) in changed code. I took the PR diff against refs/coderabbit/pre-merge-check/base and scanned all added .ts/.tsx lines (about 1,700 lines across 11 TypeScript files). I found no @ts-ignore, @ts-expect-error, @ts-nocheck, explicit any, as any, or any[] usage. I also found no non-null assertions, including x!., x![, )!, and ]!. The only as unknown as/as never search returned nothing. The new code, such as ingest.ts, listing.ts, locations.ts, and the validators, uses typed signatures and Zod schemas.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
packages/api/package.json
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
packages/api/src/job-board.server.ts
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
Other comments: 3
packages/api/src/utils/job-board/ingest.ts: 2
206-206: Minor · Data Integrity & Integration · Quick win
Keep older snapshots from replacing newer details.
If the 12:02 snapshot commits before the 12:01 snapshot, the delayed snapshot overwrites the title and other details. lastSeenAt still records 12:02.
Check seenAt against the stored freshness timestamp before replacing details. Preserve the null-safe updates for current snapshots.
193-193: Minor · Data Integrity & Integration · Quick win
Reconcile the job after insert-conflict recovery.
If another ingest inserts and closes the job after findJob returns no row, a newer snapshot can lose the insert conflict and retrieve that inactive job here. This path skips the update branch. It creates an open observation but leaves Job.active false.
Run the existing-job update path after conflict recovery.
packages/api/src/utils/job-board/locations.ts: 1
159-159: Minor · Functional Correctness · Quick win
Retain lowercase city/state locations.
With locationTexts: ["London, ky"], FOREIGN matches London, but hasUsEvidence misses ky. prepareListing then rejects the listing as non_us, although parseCityState accepts ky as KY.
Recognize state codes without case sensitivity in a city/state position. Keep the protection against bare prose tokens.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Heavy lift
Concurrent source closures can leave a job active with no open observations.
closeMissing closes one source's observations, then checks notExists(openObservation) across all sources. Under PostgreSQL READ COMMITTED, a closure from source A cannot see an uncommitted closure of the same job's observation from source B. If both full inventories overlap on a job that has only those two open observations, each check can still find the other's observation open. Neither transaction deactivates the job.
Later inventories from both sources find no newly closed observations and return at line 282. The job remains active: true with no open observations. Nothing in the inspected path corrects it.
Make deactivation of a job correct when its final open observation closes, even when full inventories from different sources overlap. The job-row lock must be taken in a statement that completes before the notExists check runs. A lock inside the same UPDATE does not provide this. Choose between serializing closures per job and retrying on serialization failure. Use the same lock order as the listing transactions.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Do not treat every numeric query value as a posting ID.
Two openings with the shared link https://acme.example/careers?year=2026 receive the same URL identity. This violates the requirement that shared careers links keep postings separate.
Accept query parameters only when their names and provider contracts identify one posting.
The reason will be displayed to describe this comment to others. Learn more.
Major · Data Integrity & Integration · Quick win
Encode source identity components without ambiguity.
boardKey="acme:engineering", externalId="17" and boardKey="acme", externalId="engineering:17" produce the same key for one provider. Both inputs pass validation. Distinct openings can therefore match the same job.
Use an unambiguous tuple encoding, such as JSON.stringify([provider, boardKey, externalId]).
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
APIChange modifies code in the global API/tRPC packageFeatureNew Feature or RequestMajorBig change - 2+ reviewers required
1 participant
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.
Why
#633 ports CS Job Poster into Forge. Cron (#652 adapters, #653 polling) fetches raw listings; this PR adds the API side that turns each source's snapshot into deduplicated
Jobrows with locations, categories, an active/inactive lifecycle, and a silent first-run baseline. #651 search, #653 and #654 build on this data.What
Closes: #649
careerJobSourceSnapshotSchemaand types in@forge/validators: the contract agreed in [SPRINT-04] Bring CS Job Poster into Forge and build a Blade Career page #633 (inventory: "full" | "rolling", optionaltrack,description,compensation).ingestJobSnapshot(snapshot, destinations)in@forge/api/job-board.server, for cron only. No tRPC procedure.Pure rules in
utils/job-board/that need no database:normalize: cleans apply URLs, builds identity keys from ATS IDs, recognizes aggregator links.classify: decides track, and category using rules ported from upstreamcategories.py.locations: parses city, state and U.S. remote, and detects foreign locations.listing: prepares each listing and records why it was rejected.Dedupe uses IDs only, strongest first:
Matching compares the hash column and also the raw key. Concurrent ingests of the same job produce one job.
Lifecycle:
pending) only when cron passes a channel for its track.Each listing is validated on its own, so one bad listing never blocks a board. Rejection reasons:
invalid_listing,invalid_apply_url,not_student_role,non_us. Any U.S. signal keeps a location ("London, KY", "ON-SITE - Austin, TX").Never creates
Companyrows. A job links to an approved Company by normalized name or alias.No schema changes. Uses the 0065 tables as merged.
Known limit (documented in the SRD): when an aggregator listing creates a job first, a later employer listing of the same posting shares no ID with it, so the job is posted twice. Mitigations are proposed for #652 (send the employer link) and #654 (posting guard).
Test Plan
pnpm format,pnpm lint,pnpm typecheck: pass. The new integration test has one max-lines warning.@forge/apipnpm testagainst local PostgreSQL 16: 151 files, 1256 tests pass. That includes the rule tests intests/job-board/ingestion-rules.test.tsand the ingest tests intests/integration/job-board-ingest.test.ts.@forge/validatorsvitest: 29 files, 380 tests pass..forge/features/career-job-ingestion/test-cases.md(TC-001 to TC-026, NEG-001 to NEG-004).Out of scope: polling, leases and error recording (#653); Discord sends (#654). Upstream's "recent catch-up" of first-run jobs is not ported, by decision.
Checklist
pnpm db:generateand committed the generated files inpackages/db/drizzle/🤖 Generated with Claude Code