pupila-filters
Skill37 starsChanged 7 months agoMITView on GitHub
How to tune job filter scoring, hard-drop rules, or debug why a specific job was kept/dropped via _signals. Use when adjusting weights in config/profile.json, adding a hard-exclude rule, tuning keyword lists, debugging fitScore, or interpreting the per-job _signals breakdown.
In this repository18 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/composition-patterns/AGENTS.mdAGENTS.md
- .agents/skills/react-best-practices/AGENTS.mdAGENTS.md
- ui/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- ui/CLAUDE.mdCLAUDE.md
- accessibilitySkill
- vercel-composition-patternsSkill
- frontend-designSkill
- nodejs-backend-patternsSkill
- nodejs-best-practicesSkill
- vercel-react-best-practicesSkill
- seoSkill
- typescript-advanced-typesSkill
- viteSkill
- vitestSkill
- pupila-ai-reviewSkill
- pupila-fetchersSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
All filter logic lives in src/filters.ts.
- Distinctive: line 82
No other plumbing — just append.
- Very specific: line 87
Add the weight to config/profile.json#weights.
- Very specific: line 129
Every kept job carries a _signals object showing which scoring rules fired:
- Very specific: line 162
When tuning a regex or weight, update tests in the same commit.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
All filter logic lives in src/filters.ts. Weights + keyword lists load from config/profile.json at runtime via loadProfile() (NOT a static import — the file is gitignored and auto-bootstrapped from config/profile.default.json on first run). Adjusting weights or keywords is a non-code edit to profile.json.
Decision tree: what kind of change are you making?
| Task | Edit | Skill section |
| Change a scoring weight (e.g. seniority +15 → +20) | config/profile.json#weights.<field> | "Tuning weights" below |
| Add/remove a keyword (e.g. another Rust framework) | config/profile.json#keywords.<list> | "Tuning keywords" below |
| Add a new hard-drop rule | src/filters.ts (HARD_RULES array) | "Adding a hard-drop rule" below |
| Add a new positive signal type | src/types.ts + config/profile.json#weights + src/filters.ts | "Adding a new positive signal" below |
| Diagnose why a job has fitScore=N | Inspect _signals on the job | "Debugging via _signals" below |
Order of operations (in applyFilters)
- Hard excludes — URL safety, junior/intern titles, location-incompatible (persona-neutral — see "Location & work type" below), non-engineering compounds, leadership, non-frontend eng (since user is a frontend engineer), non-tech roles, stale posting (
postedAtolder thanscoring.maxAgeDays, when set — not rescued by a role match; age applies regardless of fit). - Body preparation —
preparedScoringBody()strips boilerplate (EEO, privacy, "About us") and truncates toscoringBodyMaxChars(default 1500). Keyword scoring runs against this — prevents footer text like "we use Anthropic Claude internally" from landing a +20 AI signal on a backend role. Hard-drops still see the full body. - Soft scoring — additive, capped at
maxScore(100):- Categories — each configured
CategoryDefwhose keywords match adds itsweightonce (binary); defaultweight0 = pure label. Replaces the old hardcoded web3/ai signals. A job is tagged with every match (Job.categories). - Stack (+10 React/Next/TS, +5 RN/Expo, +5 GraphQL/Tailwind/Vite) — tiered
- Seniority (+15 lead/staff/principal/head, +10 senior/sr) — binary
- Frontend title (+10) — binary
- Frontend body (+10) — tiered
- Location (+10 when the job matches an accepted region / is remote — driven by the
locationblock) — binary - Freshness (+10 within 7d, +5 within 14d) — binary
- Categories — each configured
- Negative —
outOfRegionPenalty(default -10) if the job is region-locked outside the candidate's accepted regions and they haven't opted into hard-excluding. Applied after capping. (Persona-neutral; replaced the old US-centric penalty.) - Drop — anything with
fitScore < minScoreToKeep(default 30). - Categories —
job.categories= ids of everyCategoryDefwhose keywords matched (multi-label, config order);[]when none (renders under synthetic "Other"). Defined inconfig/profile.json#categories, generated from the brief on Regenerate or edited on the Profile tab. Each entry:{ id, label, keywords, scope?, weight?, limit? }.
Tiered weighting
tieredWeight(count, baseWeight) scales by occurrence:
| Matches | Weight |
| 0 | 0 |
| 1 | floor(base * 0.5) |
| 2–3 | base |
| 4+ | floor(base * 1.5) |
Implemented with global-flag regexes (STACK_PRIMARY_G, STACK_RN_G, STACK_OTHER_G, BODY_FRONTEND_KW_G) + countMatches. Other signals stay binary.
See references/scoring-tiers.md for the full tier table and per-signal regex catalog.
Tuning weights
Edit config/profile.json#weights.<field>. Re-run pnpm run dev (or just pnpm run ui — it reads the same file). No code change needed.
Age cutoff (scoring.maxAgeDays)
config/profile.json#scoring.maxAgeDays (optional, default null/unset — inert) hard-drops any posting whose postedAt is older than N days, as the stale_posting rule in HARD_RULES. Unlike the title-based hard-drops, it is not in ROLE_RESCUABLE_RULES — a perfect role-title match doesn't save a stale posting. A missing or unparsable postedAt is kept, not dropped (no evidence of staleness). Non-code, purely a config/profile.json#scoring edit.
Tuning keywords
Edit config/profile.json#keywords.<list>. compileKw() joins each list with | and wraps in \b...\b/i at runtime. Lists currently include:
seniorReq,engineeringKw(whitelists — kept jobs must match these)nonEngineering,nonFrontendEng,nonEngLeadership,nonEngCompound,nonEngRole,nonTechRole(blacklists — drop on title match)stackPrimary,stackRn,stackOther(scoring signals)profile.json#categories[]: user-defined taxonomy ({ id, label, keywords, scope?, weight?, limit? }). Each match tagsjob.categoriesand addsweightto the score. Replaced the old hardcodedweb3*/ai*keyword groups. Categorykeywordsare plain LITERAL terms, not regex (unlike every list above): they're matched whole-word + case-insensitive bycompileCategoryKeywords()insrc/filters.ts, which anchors with alphanumeric lookarounds instead of\b, so punctuation-edged terms work (c++,c#,.net) and a dot between words is optional (node.jsalso matchesnodejs). List both for other variants (agent/agents). Edit by hand, regenerate from the brief, or use the Profile-tab editor (ui/src/CategoryPreferences.tsx); validated bysanitizeCategories()(literal-only, no regex compile) insrc/lib/profile-generator.ts.profile.json#roles[]— target job titles ({ id, label, titleMatch, bodyMatch? }); driveroleTitle/roleBody+job.roleMatches+ the hard-drop rescue (seereferences/scoring-tiers.md)locationLock,onsiteOnly,worldwideRemote— persona-neutral geo extraction groups (no country names); the keep/drop decision compares them againstprofile.json#location(see "Location & work type" below)locationRemote— fallback remote signal only used when a profile has nolocationblock
Adding a hard-drop rule
HARD_RULES in src/filters.ts is a named-rule list. applyFilters runs Array.find over the rules, increments droppedHard, and tallies the rule name in droppedByRule. Breakdown surfaces in JOBS.md (e.g. (missing_senior_req=812, ...)).
HARD_RULES.push({
name: 'descriptive_rule_name',
test: (job, ctx) => /* return true to drop */,
});No other plumbing — just append.
Adding a new positive signal
- Append the field to
JobSignalsinsrc/types.ts. - Add the weight to
config/profile.json#weights. - Append one line to the
positivesobject literal inapplyFilters.
The sum is Object.values(positives).reduce(...) — auto-includes any new field. No need to update the sum site.
Location & work type (persona-neutral geo)
Geo handling is driven entirely by the location block in config/profile.json — no country is privileged (a US-based and an EU-based profile get opposite outcomes from the same code; see the symmetry test in tests/filters.test.ts). Editable on the Profile tab (ui/src/LocationPreferences.tsx) or derived from the brief during Regenerate.
"location": {
"basedIn": "Spain", // where the candidate lives (single)
"workTypes": ["remote", "hybrid"], // accepted arrangements: remote | hybrid | onsite
"acceptedRegions": ["europe", "emea", "eu", "spain"], // region terms they'll work in (lowercased)
"excludeOutsideAcceptedRegions": true // true = hard-drop out-of-region; false = soft-penalize
}How hard_location_incompatible decides (rescue-first):
- Work-type gate — if the candidate doesn't accept
onsite, the job isn't remote, and the text matchesonsiteOnly→ drop. - Region gate (only when
excludeOutsideAcceptedRegionsand a region preference exists):- Rescue first — if the posting names an accepted region /
basedIn/worldwideRemoteanywhere, keep it (a "Remote - US" label whose body welcomes Europe survives).regionAccepted()deliberately does NOT treat a bare "remote" as a region. - Else drop if the body (or location text) declares a real lock (
locationLock— work authorization / must-be-based-in / timezone-required / a "REMOTE (EU)"-style bare region-code annotation) or, only for a non-remote posting, its stated location names a specific non-accepted place (locationFieldOutOfRegion()— strips generic-remote tokens; "Remote" alone → empty residual → kept; "Remote, US" → "us" → dropped, but only whenjob.remoteis false).
- Rescue first — if the posting names an accepted region /
Key invariants:
workTypesis only lightly wired:onsitecontrols the drop gate,remotefeeds the+locationRemotebonus, andhybridcombines withonsiteto gate the separateconfirmed_not_remoterule below (still otherwise unused).- Bare "Remote"/"Worldwide"/"Global"/"Distributed" are always kept — a job does NOT need a region word to survive. Only an explicit non-accepted location requirement drops it.
locationFieldOutOfRegion()only fires for a non-remote posting (!job.remote). For an actually-remote posting, a bare named place injob.location(e.g. "Canada (Remote)", "London, UK") states where the team/hub sits, not a requirement on the candidate — it survives unlesslocationLock/ROLE_SPECIFIC_LOCATION_STATEMENTfinds explicit restriction language (e.g. "Only Europe", "must be based in", a specific timezone mandate, "REMOTE (EU)"). This matters most for a candidate who has worked async with EU/US-based teams from elsewhere for years: the team's location isn't their eligibility. A genuinely onsite/physical posting (job.remote === false) in a non-accepted place still hard-drops on the bare location alone, with or without lock language.- Empty
acceptedRegions+ emptybasedIn→ region logic is inert (a fresh fork drops nothing on geography). locationLock/onsiteOnly/worldwideRemoteare neutral extraction groups; tune the candidate's preference in thelocationblock, not those lists.locationLockincludes a bare-region-code fragment (remote\s*\((eu|us|uk|apac|...)\b...(?=\))) alongside the older-only-suffixed one, so "REMOTE (EU)" locks the same as "REMOTE (US-only)" even without the word "only". It's an enumerated word list, not an open wildcard — an open[a-z]+here would also catch unrelated parentheticals like "remote (async only)" (a work-style note, not geography), which is exactly the false positive a test intests/filters.test.tsguards against. Extend the enumeration, don't loosen it to a wildcard. A candidate whose ownacceptedRegionsincludes the same code (e.g.apac) is unaffected —ACCEPTED_REGIONS_SPECIFICrescues it earlier inhard_location_incompatible, before this fragment is ever reached. Especially relevant for sources likehn-hiringwhose normalizer never populates the structuredlocationfield — this is the only signal available for those postings.locationLockalso includes security-clearance / citizenship fragments (public trust,(security|secret|top secret) clearance,clearance required,must be a (u.s.|united states) citizen,citizenship required). A clearance requirement is a distinct kind of explicit restriction from a named location — it's a proxy for "must be a US citizen able to pass a federal background investigation," which excludes a non-US-citizen candidate regardless of the "Remote" label. These fire via the sameLOCATION_LOCK.test(haystack)check and are deliberately NOT gated onjob.remote— a clearance requirement is a hard requirement even for a fully-remote role, unlike a bare named location. Observed live: a "Senior Front-End Agentic AI Engineer" at a VA (Veterans Affairs) contractor, location "United States - Remote," body "Clearance: Ability to obtain and maintain a Public Trust" — survived until this fragment was added, since remote + a bare US location isn't itself a restriction (previous bullet) and none of the work-authorization/visa phrasing matched clearance-specific language.
hard_timezone_incompatible — required working hours in a far-away zone. Opt-in via location.utcOffset (candidate's UTC offset in hours, e.g. 7) and optional location.maxTimezoneDiffHours (default 8). Scans title + full body for zones named next to working-hours language ("EST hours", "overlap with Pacific", "US business hours", "UTC-8 to UTC-5") and drops the posting only when every stated zone is further than the max gap; any zone within reach ("CET or EST") keeps it. Not role-rescuable. Abbreviations match uppercase only (ET/PT/CT collide with words). Inert when utcOffset is unset. Hand-set (never LLM-generated); sanitizeLocation() preserves it across UI edits. Tests: tests/filters-timezone.test.ts. Gaps are measured around the clock (UTC+10 and UTC−8 are 6h apart). Two-letter abbreviations (PT/MT/CT/ET) and CST only count when glued to clock or schedule wording ("9-5 ET", "overlap with PT", "ET hours"), because they collide with ordinary text; capitalised US/U.S. is required for "US hours". Sentences with "try to" / "ideally" / "preferred" are left to the AI review.
confirmed_not_remote — a separate, stricter rule for trusted-source data. onsiteOnly text-matching misses a lot: many ATS postings just never phrase the requirement as "onsite only" in prose, even when the ATS's own structured field says the role isn't remote. For sources whose remote flag is read directly off a structured field rather than inferred from text — lever (workplaceType), ashby/ashby-private (isRemote/workplaceType), recruitee (remote boolean), aave (workplaceType) — remote: false is a confirmed signal, not a guess. When the candidate is remote-only (workTypes has neither onsite nor hybrid) and has a location block configured at all, a false from one of those sources hard-drops regardless of body text. Not rescued by a role match (same rationale as hard_location_incompatible). Deliberately excludes heuristic sources (greenhouse, personio, bluedoor, every scraper/aggregator) whose remote field can genuinely mean "couldn't tell" rather than "confirmed onsite" — extending this rule to those sources would risk dropping real remote jobs. Inert with no location block (no default-deny for a fresh fork). A posting whose stated location says Remote/Worldwide (with no hybrid or on-site wording) is not treated as confirmed on-site, because a missing workplace type reads as remote: false (Ashby: remote = isRemote || workplaceType === 'Remote'). This rule did not exist before: it only affects candidates with a location block that accepts neither on-site nor hybrid.
UI/data plumbing: useLocation hook + api.location ↔ GET/PUT /api/profile-location (ui/plugins/profile.ts); sanitizeLocation() validates both LLM and UI input (src/lib/profile-generator.ts).
Debugging via _signals
Every kept job carries a _signals object showing which scoring rules fired:
"_signals": {
"categories": { "web3": 20, "ai": 20 }, // id → weight contributed; mirrors job.categories
"stackPrimary": 10, "stackRn": 0, "stackOther": 0,
"leadTitle": 0, "seniorTitle": 10,
"roleTitle": 10, "roleBody": 10, "locationRemote": 10,
"freshness7d": 10, "freshness14d": 0, "outOfRegionPenalty": 0,
"rawTotal": 100, "capped": false
}_signals.categorieskeys are exactlyjob.categories; a value of 0 = a matched pure-label category.rawTotalis the un-capped positive sum.capped: truemeans positives summed > 100 before clamping.outOfRegionPenaltyis applied after capping.
Inspecting in-place
pnpm run dev
jq '.[0]._signals' data/jobs.json # first job
jq '.[] | select(.id == "<sha1>") | ._signals' data/jobs.json # specific job
jq '.[] | select(._signals.rawTotal > 100) | {company,title}' data/jobs.json # cappedIn the UI
The Jobs-tab detail panel (click a row) renders the _signals breakdown alongside the AI take and meta. Tier-coloured cells: green ≥80, gold 50–79, muted <50.
Updating tests when tuning
When tuning a regex or weight, update tests in the same commit. The frozen fixture lives at tests/fixtures/test-profile.json — bake new expected scores into tests/filters.test.ts (40 cases). Don't loosen the assertion to make a failing test pass.
Related
src/filters.ts— all logic.tests/filters.test.ts— every hard-drop branch, scoring signal, tiered weighting, boilerplate stripping.config/profile.json(gitignored) /config/profile.default.json(committed baseline).pupila-ai-reviewskill — when filters and AI verdicts disagree, the brief is usually the lever.
Accepting a region accepts the countries inside it. regionAccepted() also tests the broader region labels implied by countries named in a short text (REGION_GROUPS in src/filters.ts: "Spain, Portugal" counts as europe/eu/emea; Singapore as apac/asia). Without this, a candidate who accepts europe lost postings that list EU countries. It only applies to location/title-sized strings, never the body.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

