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.
CodeRabbit could not verify the path filters used for the saved review. Run a full review using the repository's approval configuration.
A reviewer can post @coderabbitai approve as a new top-level comment to request approval.
Commit: fa0a12e9a97f.
Walkthrough
The change adds snapshot and listing validation, identity normalization, track and category classification, U.S. location parsing, and job ingestion in @forge/api. Ingestion supports source baselines, job matching, observation updates, and full-inventory closure. Unit and database integration tests cover these behaviors.
Merge Risk: Moderate · up to fa0a1
Ingestion handles the main lifecycle cases, but a few edge cases can still create duplicate or stale jobs. These are concurrent same-source runs, identities learned after the first sighting, and out-of-order snapshots. The same-source cases rely on the follow-up source claim to serialize runs. Review these and the minor comments before relying on this for Discord posting.
Pre-merge checks: 6 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Title check
The title lacks the required issue-number prefix in brackets. It names the main change (career job ingestion, dedupe, classification) and matches the PR's objectives. Length is 58 characters, under th…
Change the title to start with the bracketed issue number, for example "[#649] Add career job ingestion, dedupe and classification". The current "[#649]" tag is present but must be kept at the start; verify the required format is "[#649] ..…
Passed checks: 6 passed
Check name
Status
Explanation
Description check
The description explains the purpose, the ingestJobSnapshot API, the validator schema, dedupe and lifecycle rules, rejection reasons, test results, and known limits. All of this matches the changeset.
Linked Issues check
Only #649 is directly linked and active. Its Done-when is parsing, deduplication, and baseline verification across source types. The summary shows: - Cron input contract: `careerJobSourceSnapshotSchem…
Out of Scope Changes check
Every changed area maps to #649 or its supporting work: - Validator contract and consts (JOB_SOURCE_INVENTORIES): snapshot contract. - packages/api/package.json and job-board.server.ts: cron-onl…
No Hardcoded Secrets
No hardcoded secrets in the PR diff (base..head, 16 changed files). Checks run on added lines: - Searched for API-key, token, password, secret, private-key, and vendor-prefix patterns (sk-, ghp_, xox,…
Validated Env Access
No direct process.env access was introduced. I checked the full added-line set of the PR diff (refs/coderabbit/pre-merge-check/base to head) for process.env and found no matches. I also search…
No Typescript Escape Hatches
No added TypeScript line in the PR range uses an escape hatch the check forbids. I scanned all 2,183 added lines in the .ts files of refs/coderabbit/pre-merge-check/base..head. - any type: none.…
Full details: Linked Issues check
Explanation
Only #649 is directly linked and active. Its Done-when is parsing, deduplication, and baseline verification across source types. The summary shows:
Cron input contract: careerJobSourceSnapshotSchema in packages/validators/src/job-board.ts.
Grouping by company and matching approved companies by key or alias: companyKey in normalize.ts, approved-company matching in ingest.ts.
Dedupe across sources: identityKeys in normalize.ts (ATS ID, cleaned URL, source key) and hash/raw-key matching in ingest.ts. Integration tests cover cross-source merge and concurrent first runs.
Location and category classification: locations.ts and classify.ts, with rule tests in ingestion-rules.test.ts.
First seen, last seen, and active state: observation tracking and full-inventory closure in ingest.ts.
Silent first-run baseline: baselined result and suppressed delivery, covered by job-board-ingest.test.ts.
The #649 scope line 'inactive listings are excluded from default search' is not implemented here. The PR description assigns search to #651, and the Done-when does not require it. Search exclusion is treated as deferred, not missing. Evidence is the PR summary; no further source inspection was made.
Full details: Out of Scope Changes check
Explanation
Every changed area maps to #649 or its supporting work:
Validator contract and consts (JOB_SOURCE_INVENTORIES): snapshot contract.
packages/api/package.json and job-board.server.ts: cron-only export of ingestJobSnapshot.
utils/career/us-cities.ts (findUsCity): reused by location parsing.
Tests under packages/api/src/tests/.
.forge/features/career-job-ingestion/*: spec, SRD, status, and test cases for this feature.
No tRPC procedure, schema change, polling, leases, or Discord send code appears in the summary. Those items are excluded by the PR description and assigned to #653 and #654.
Full details: No Hardcoded Secrets
Explanation
No hardcoded secrets in the PR diff (base..head, 16 changed files). Checks run on added lines: - Searched for API-key, token, password, secret, private-key, and vendor-prefix patterns (sk-, ghp_, xox, AKIA, PEM headers). The only hit was if (url.username || url.password) return null; in normalize.ts, which is logic, not a value. - Searched for connection strings and credentialed URLs. The only credential-like literal is https://user:pw@acme.com/jobs/9 in ingestion-rules.test.ts. It is a placeholder fixture that tests rejection of URLs with credentials. - The database URL is injected at test time through vi.stubEnv("DATABASE_URL", database.url), where the URL comes from a disposable database helper. It is not a literal. - The 64-hex string in the identityHash test is the published SHA-256 digest of "abc", not a secret. No live credentials were found.
Full details: Validated Env Access
Explanation
No direct process.env access was introduced. I checked the full added-line set of the PR diff (refs/coderabbit/pre-merge-check/base to head) for process.env and found no matches. I also searched the head version of every changed file (15 files, including the new job-board.server.ts, ingest.ts, normalize.ts, classify.ts, locations.ts, listing.ts, the validators, consts, and the tests) and found no process.env usage. The check's failure condition is therefore not met.
Full details: No Typescript Escape Hatches
Explanation
No added TypeScript line in the PR range uses an escape hatch the check forbids. I scanned all 2,183 added lines in the .ts files of refs/coderabbit/pre-merge-check/base..head. - any type: none. The only whole-word matches are in comments ("in any order", "in any case"). - @ts-ignore, @ts-expect-error, @ts-nocheck: none. - Non-null assertions (x!., x![, x!), x!,, x!;, and similar): none. The added code does use as type assertions (for example as const, as Record<PatternKey, RegExp>, as PatternKey[]). The check does not list type assertions, so they do not trigger this FAIL. I did not evaluate them further.
Full details: Title check
Explanation
The title lacks the required issue-number prefix in brackets. It names the main change (career job ingestion, dedupe, classification) and matches the PR's objectives. Length is 58 characters, under the 72-character limit.
Resolution
Change the title to start with the bracketed issue number, for example "[#649] Add career job ingestion, dedupe and classification". The current "[#649]" tag is present but must be kept at the start; verify the required format is "[#649] ..." with the issue number in brackets as the first element.
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
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
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.
Actionable comments posted: 10
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
Other comments: 8
packages/api/src/utils/job-board/ingest.ts: 3
403-403: Minor · Data Integrity & Integration · Quick win
Set the baseline with a conditional database update.
Two runs that read an unset baseline can both return baselined: true, and the last one overwrites the first completion time. Set baselineCompletedAt only where it is still null. Use the returned row to report which run set it, and record lastSuccessAt for both successful runs.
247-249: Minor · Data Integrity & Integration · Quick win
Do not overwrite newer observation metadata on a stale replay.
A t10 sighting can replace sourceUrl, sourceData, and postedAt written at t20 while lastSeenAt stays at t20. Update these fields only when the incoming sighting is at least as recent as the stored observation. Keep the separate reopen check.
379-379: Minor · Performance & Scalability · Heavy lift
Batch the snapshot's lookup queries.
A snapshot of 1,000 unchanged listings makes at least 3,000 sequential read queries for observations, jobs, and existing locations, before writes. Batch these lookups for the snapshot or bounded chunks. Retain the locked checks that protect writes from concurrent changes.
As per path instructions, “No N+1 query patterns.”
Source: Path instructions
packages/api/src/utils/job-board/normalize.ts: 1
42-42: Minor · Functional Correctness · Quick win
Preserve fragments that are part of the application route.
On a hash-routed board, /careers#/jobs/42 links to a posting. Clearing the fragment stores /careers instead. Use the cleaned URL for matching and preserve the validated navigation URL for Job.applyUrl. (url.spec.whatwg.org)
.forge/features/career-job-ingestion/srd.md: 2
84-85: Minor · Data Integrity & Integration · Quick win
Document where company merges are resolved.
loadCompanyIds reads approved companies and their aliases. It does not follow mergedIntoCompanyId. Remove that claim from the ingestion field rules and note that API reads resolve company merges.
Based on learnings, “Resolve Company merges in API reads.”
Source: Learnings
28-29: Minor · Data Integrity & Integration · Quick win
Do not require whole-snapshot validation before per-listing rejection.
careerJobSourceSnapshotSchema rejects the entire snapshot if one listing has a blank title. If cron uses it as a gate, valid siblings never reach Step 4. Document that ingestion validates the envelope first and validates each listing separately.
packages/api/src/utils/job-board/locations.ts: 1
208-208: Minor · Functional Correctness · Quick win
Parse mixed location alternatives before filtering them.
Austin, TX or Toronto, ON stays in scope because it contains TX, but it is not split. The parser reads ON as the final state field and stores unknown, so an Austin filter misses the listing. Split location alternatives before applying the foreign-location filter.
204-208: Minor · Maintainability & Code Quality · Quick win
Make the silent-reopen test detect requeueing.
The job is pending before closure and expected to be pending after reopening. A regression that resets delivery to pending would pass. Arrange a sent job with a valid delivery receipt, then assert that reopening preserves its delivery state and receipt.
As per path instructions, “Check for meaningful descriptions, proper assertions, and no skipped tests without explanation.”
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
- Reject lone surrogates in every listing text field, so a stored
externalId can't mismatch on the next run and stall the source
- Workday keys need a real tenant (path tenant on myworkdaysite.com)
- *_id filter params (department_id) no longer make a URL identity
- #// hash routes no longer throw
- Tests: ATS-only cross-source merge, job-level stale reopen,
concurrent two-source close
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
For https://acme.com/jobs/1234#/overview, path becomes the hash path /overview. The real path /jobs/1234 is never checked. pathId is false, so identityKeys omits the url: key. Cross-source matching then falls back to the source key, and the same posting can be posted twice. Check url.pathname and the hash path separately.
text() runs storable first, and .transform then cuts the string at 20,000 UTF-16 code units. If code unit 19,999 is the high half of a surrogate pair, the cut leaves a lone high surrogate. Nothing re-checks the result. PostgreSQL stores it as U+FFFD, which is the mismatch that the comment at lines 311-314 says the schema must prevent. Drop a trailing high surrogate after the cut. A complete pair ends in a low surrogate, so it is kept. Add a test with a 19,999-character prefix followed by an emoji.
Proposed fix
- .transform((value) => value.slice(0, 20_000))
+ .transform((value) => {
+ const cut = value.slice(0, 20_000);
+ // The cut can split a surrogate pair; drop the orphaned high half.
+ return /[\uD800-\uDBFF]$/.test(cut) ? cut.slice(0, -1) : cut;
+ })
As per path instructions, packages/validators/** must have "Comprehensive validation rules with clear error messages."
ingestJobSnapshot writes Job, JobObservation, JobLocation and JobSource rows. The "Data / migration / compatibility" section says only "No schema change." A full inventory closes every omitted observation and can deactivate jobs. A bad or empty full snapshot from cron therefore needs a documented recovery. Add the rollout order (`#652`, `#653`, `#654` wiring and the first-run baseline) and a rollback or repair procedure for a wrongly closed source.
Based on learnings, "SRDs that touch production data should include data-change flows, caveats, validation expectations, rollout plans, and rollback notes."
Source: Learnings
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve the employer’s application link.
If an employer serves a posting only at /apply, removing that segment stores a link to a different endpoint. The user may not be able to apply. Keep the validated application URL for use as a link, and test identity normalization separately.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
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
2 participants
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