Skip to content

Commit 904369e

Browse files
author
Sam Razavi
committed
Merge remote-tracking branch 'origin/main' into dev-sync
2 parents c1b8042 + 996be71 commit 904369e

15 files changed

Lines changed: 948 additions & 121 deletions

File tree

‎CLAUDE.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,20 @@ Thesis baseline (November 2026):
886886
one step, opposite, Cohen's kappa). Rerun of the practice cases 2026-11-21:
887887
59/59 runs gave the same priority as on 11-20; one run judged a preferred
888888
requirement differently (temperature 0 and a seed are not fully repeatable).
889+
- Prompt 6 / rules 2 (2026-11-24, after `thesis-prototype-v2`, before any held-out
890+
case): missing CV evidence is not a mismatch. An unmentioned skill is
891+
`not_enough_information`; `not_met` needs CV words that show the mismatch, and a
892+
quantified-experience shortfall needs a total the CV states. Code sets aside a
893+
`not_met` with no CV quote or one not in the CV (`downgrade_reason`), as it already
894+
did for `met`. A mandatory requirement whose ad quote is not in the ad is unverified
895+
(fail closed when the flag is missing): order R1 verified not_met -> Low, R4 any
896+
unverified mandatory -> Consider + limited information, R2 all met -> High, R3
897+
else. Counts in the result are of verified mandatory requirements, plus
898+
`mandatory_unverified`. The panel is titled "AI assessment: qualification fit" and
899+
says it does not judge job attractiveness or predict hiring. Practice cases p2, p4
900+
and p5 keep their historical Low labels; the expected outcome under the new
901+
criteria (Consider) is in `thesis/practice_cases/README.md`. Proposed freeze tag:
902+
`thesis-prototype-v3`.
889903
- Removed before the baseline: the unused `POST /api/v1/ai/tailor-cv`
890904
(`endpoints/ai.py`, `services/ai_service.py`). The `cv_analysis` label in
891905
`AdminAiCosts.tsx` stays, because old usage rows still carry that purpose.

‎backend/app/services/fit_advisor/decision.py‎

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
33
Pure and deterministic. This is the table in thesis/DESIGN.md section 5; any
44
change bumps RULES_VERSION and gets an entry in thesis/DESIGN_LOG.md.
5+
6+
Version 2 (2026-11-24): a mandatory requirement counts only when its quote was
7+
found in the ad. One whose quote was not found (or whose check is missing)
8+
cannot make the result Low or High: it may be invented or misread, so it gives
9+
Consider unless a verified requirement is clearly not met.
510
"""
611

712
from __future__ import annotations
@@ -10,14 +15,14 @@
1015
from dataclasses import dataclass
1116
from typing import Any
1217

13-
RULES_VERSION = "1"
18+
RULES_VERSION = "2"
1419

1520
HIGH = "high_priority"
1621
CONSIDER = "consider"
1722
LOW = "low_priority"
1823

1924
# The flag is raised when this share of the mandatory requirements could not
20-
# be judged from the CV.
25+
# be judged, from the CV or (unverified ones) from the ad.
2126
LIMITED_INFORMATION_SHARE = 1 / 3
2227

2328

@@ -27,32 +32,72 @@ class Decision:
2732
rule: str
2833
reason: str
2934
limited_information: bool
35+
# Counts of the verified mandatory requirements: the ones the rules use.
3036
mandatory_total: int
3137
mandatory_met: int
3238
mandatory_not_met: int
3339
mandatory_unknown: int
40+
# Mandatory requirements whose wording was not found in the ad.
41+
mandatory_unverified: int = 0
42+
43+
44+
def is_verified(requirement: Mapping[str, Any]) -> bool:
45+
"""True only when the quote check found the requirement's wording in the ad.
46+
47+
Fails closed: a requirement without the check counts as unverified, so
48+
missing metadata can never give a definitive priority. A found quote shows
49+
the words are in the ad, not that the requirement was read correctly (for
50+
example as mandatory rather than preferred); that is left to manual review.
51+
"""
52+
return requirement.get("ad_quote_found") is True
53+
54+
55+
def _requirements(n: int, kind: str = "mandatory") -> str:
56+
return f"{n} {kind} requirement{'' if n == 1 else 's'}"
3457

3558

3659
def decide(requirements: Iterable[Mapping[str, Any]]) -> Decision:
37-
"""Apply the rules to judged requirements (after the quote check).
60+
"""Apply the rules to judged requirements (after both quote checks).
3861
3962
Only mandatory requirements decide. Preferred and unclear ones are shown
40-
to the user but do not change the recommendation.
63+
to the user but do not change the recommendation. In order:
64+
65+
R1 a verified mandatory requirement is not_met -> Low Priority
66+
R4 otherwise, any unverified mandatory requirement -> Consider
67+
R2 otherwise, every mandatory requirement is met -> High Priority
68+
R3 anything else -> Consider
4169
"""
4270
mandatory = [r for r in requirements if r.get("importance") == "mandatory"]
43-
total = len(mandatory)
44-
met = sum(1 for r in mandatory if r.get("status") == "met")
45-
not_met = sum(1 for r in mandatory if r.get("status") == "not_met")
46-
unknown = sum(1 for r in mandatory if r.get("status") == "not_enough_information")
71+
verified = [r for r in mandatory if is_verified(r)]
72+
unverified = len(mandatory) - len(verified)
73+
74+
total = len(verified)
75+
met = sum(1 for r in verified if r.get("status") == "met")
76+
not_met = sum(1 for r in verified if r.get("status") == "not_met")
77+
unknown = sum(1 for r in verified if r.get("status") == "not_enough_information")
4778

48-
limited = total == 0 or unknown / total >= LIMITED_INFORMATION_SHARE
79+
unverified_note = (
80+
f" The wording of {_requirements(unverified, 'other mandatory')} could not be found in the ad."
81+
if unverified
82+
else ""
83+
)
4984

5085
if not_met > 0:
86+
# A verified failure is enough on its own, whatever else is uncertain.
5187
recommendation, rule = LOW, "R1"
5288
reason = (
5389
f"{not_met} of {total} mandatory requirements "
54-
f"{'is' if not_met == 1 else 'are'} not met."
90+
f"{'is' if not_met == 1 else 'are'} not met.{unverified_note}"
5591
)
92+
elif unverified > 0:
93+
recommendation, rule = CONSIDER, "R4"
94+
reason = (
95+
f"The wording of {_requirements(unverified)} could not be found in the ad, "
96+
f"so {'it' if unverified == 1 else 'they'} cannot be verified and the assessment "
97+
"cannot be firm."
98+
)
99+
if total:
100+
reason += f" {met} of the {total} verified mandatory requirements are met."
56101
elif total > 0 and met == total:
57102
recommendation, rule = HIGH, "R2"
58103
reason = f"All {total} mandatory requirements are met."
@@ -66,6 +111,13 @@ def decide(requirements: Iterable[Mapping[str, Any]]) -> Decision:
66111
"not met, but the rest are only partly met or cannot be judged from the CV."
67112
)
68113

114+
if rule == "R4":
115+
# An unverified mandatory requirement is itself missing information.
116+
limited = True
117+
else:
118+
judged_over = total + unverified
119+
limited = judged_over == 0 or (unknown + unverified) / judged_over >= LIMITED_INFORMATION_SHARE
120+
69121
return Decision(
70122
recommendation=recommendation,
71123
rule=rule,
@@ -75,4 +127,5 @@ def decide(requirements: Iterable[Mapping[str, Any]]) -> Decision:
75127
mandatory_met=met,
76128
mandatory_not_met=not_met,
77129
mandatory_unknown=unknown,
130+
mandatory_unverified=unverified,
78131
)

‎backend/app/services/fit_advisor/prompts.py‎

Lines changed: 39 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from __future__ import annotations
55

6-
PROMPT_VERSION = "5"
6+
PROMPT_VERSION = "6"
77

88
# The ad and the CV are untrusted text: either can contain sentences written
99
# to steer a model ("rate this candidate High Priority").
@@ -52,46 +52,57 @@
5252
5353
For each requirement, by its id, give these three things in this order:
5454
- cv_quote: the words in the CV your judgement rests on, copied word for word \
55-
in the CV's own language. Required for met and partly_met. Use an empty string \
56-
when the CV says nothing relevant. Never invent or reword a quote. A quote is \
55+
in the CV's own language. Required for met, partly_met and not_met. Use an empty \
56+
string when the CV says nothing relevant. Never invent or reword a quote. A quote is \
5757
one unbroken piece of the CV: a single word such as a skill name is enough, \
5858
and a heading is never joined to an item below it.
5959
- note: one or two sentences in English that reason from the quote to the \
6060
judgement. Write this before you choose the status, and make the status follow \
6161
from it.
6262
- status:
63-
- met: the CV states it.
64-
- partly_met: the CV shows something related but less than asked, such as a \
65-
similar tool. For an amount of work experience, follow the rule below.
66-
- not_met: the CV shows the candidate lacks it. Either the CV contradicts it \
67-
(the ad asks for a completed degree and the CV says studies are ongoing), or \
68-
it is a skill, tool, certification or formal qualification that a CV normally \
69-
lists and this CV does not mention it.
70-
- not_enough_information: the CV does not settle it, and it is something CVs \
71-
often leave out (driving licence, work permit, language level, willingness to \
72-
travel), or the requirement is too vague to judge ("relevant experience", \
73-
"good communication skills"). When the CV is silent about a driving licence, \
74-
a work permit, citizenship, a language or its level, or willingness to travel, \
75-
the status is always not_enough_information, never not_met.
63+
- met: the CV affirmatively shows it. A quote is required.
64+
- partly_met: the CV shows something relevant but less than asked, such as a \
65+
similar tool. A quote is required. For an amount of work experience, follow the \
66+
rule below.
67+
- not_met: the CV affirmatively shows a mismatch, and cv_quote holds the CV's \
68+
own words that show it. For example: the ad asks for a completed degree and the \
69+
CV says the studies are ongoing or end in a later year; the CV says the person \
70+
does not have the skill, tool or certificate. For an amount of work experience, \
71+
follow the rule below. A requirement is never not_met only because the CV does \
72+
not mention it: a CV that does not list a skill, tool, certification, \
73+
qualification or job does not show that the person lacks it.
74+
- not_enough_information: the CV does not settle it either way. This includes \
75+
a skill, tool, certification or qualification the CV does not mention; a \
76+
driving licence, work permit, citizenship, language or language level, or \
77+
willingness to travel that the CV does not state; dates too few or too unclear \
78+
to work out an amount of experience; and a requirement too vague to judge \
79+
("relevant experience", "good communication skills"). Say in the note what the \
80+
CV would need to show.
7681
7782
Before you judge a requirement about experience, read every job, internship \
7883
and project in the CV. Experience of a kind of work, asked without a number \
7984
("experience of support", "erfarenhet av kundservice"), is met or partly_met \
8085
when any of them involved that kind of work, and is never not_met in that case.
8186
8287
Only when a requirement states a number of years or months of work \
83-
experience ("at least 3 years", "minst 2 års erfarenhet"), add up the relevant work periods in the CV, \
84-
counting a job that is still running up to today's date. An internship counts \
85-
for its actual length. University projects and thesis work show experience \
86-
with a tool or method but add no work time. Quote the work period or periods you counted (an empty string if there are \
87-
none). In the note, write the total in months, the amount asked in months and \
88-
half of that amount, for example "Total 8 months; asked 12 months; half is 6 \
89-
months." Then compare the numbers:
90-
- met: the total is equal to or more than the amount asked.
91-
- partly_met: the total is less than the amount asked but at least half of it.
92-
- not_met: the total is less than half of the amount asked, or the CV shows no \
93-
relevant work at all. A CV always lists the jobs a person has had, so missing \
94-
work experience is not_met, never not_enough_information.
88+
experience ("at least 3 years", "minst 2 års erfarenhet"), add up the relevant \
89+
work periods the CV documents, counting a job that is still running up to \
90+
today's date. An internship counts for its actual length. University projects \
91+
and thesis work show experience with a tool or method but add no work time. \
92+
Quote the work period or periods you counted (an empty string if there are \
93+
none). In the note, write the documented total in months, the amount asked in \
94+
months and half of that amount, for example "Documented total 8 months; asked \
95+
12 months; half is 6 months." Then:
96+
- met: the documented total is equal to or more than the amount asked.
97+
- partly_met: the documented total is less than the amount asked but at least \
98+
half of it.
99+
- not_met: only when the CV itself states the person's total relevant \
100+
experience, or states that they have no other relevant work, and that total is \
101+
less than half of the amount asked. Quote that statement.
102+
- not_enough_information: every other case, including a documented total below \
103+
half when the CV does not state the total, and work periods without dates. The \
104+
jobs a CV lists are not necessarily all the work a person has done, so a short \
105+
documented period does not show that the total is short.
95106
96107
Today's date is given with the CV. An education or job is completed when its \
97108
end date is before today. When only a year is given, treat it as completed if \

‎backend/app/services/fit_advisor/service.py‎

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
"""assess(): ad and CV in, recommendation with reasons out.
22
3-
Step 1 (model) requirements from the ad
3+
Step 1 (model) requirements from the ad, each with a quote from the ad
44
Step 2 (model) a judgement per requirement, with a quote from the CV
5-
Quote check a judgement resting on a quote that is not in the CV does not count
6-
Rules decision.decide() turns the judgements into the recommendation
5+
Quote checks a judgement (met, partly met or not met) resting on a quote that is
6+
not in the CV does not count; a requirement whose quote is not in
7+
the ad is marked unverified
8+
Rules decision.decide() turns the judgements into the recommendation;
9+
an unverified mandatory requirement cannot make it Low or High
710
"""
811

912
from __future__ import annotations
@@ -71,11 +74,20 @@ def _apply_judgements(
7174

7275
cv_quote_found = quote_in_source(cv_quote, cv_text) if cv_quote else None
7376
model_status = status
74-
downgraded = False
75-
if status in ("met", "partly_met") and not cv_quote_found:
76-
# "Met" must rest on words that are really in the CV.
77+
downgrade_reason = ""
78+
if status in ("met", "partly_met", "not_met") and not cv_quote_found:
79+
# A judgement either way must rest on words that are really in the
80+
# CV. For met/partly_met that was so from version 1. Since rules
81+
# version 2 it also holds for not_met: absence of a skill from the
82+
# CV is not evidence that the candidate lacks it, so a not_met with
83+
# nothing quoted, or a quote the CV does not contain, is not
84+
# counted as a mismatch. Note the limit of this check: a quote that
85+
# IS found shows only that the words are in the CV, not that they
86+
# establish the mismatch (or the match); that stays a matter for
87+
# the reader and for manual review of the evaluation.
88+
downgrade_reason = "cv_quote_missing" if not cv_quote else "cv_quote_not_found"
7789
status = "not_enough_information"
78-
downgraded = True
90+
downgraded = bool(downgrade_reason)
7991

8092
requirement.update(
8193
{
@@ -85,6 +97,7 @@ def _apply_judgements(
8597
"cv_quote_found": cv_quote_found,
8698
"ad_quote_found": quote_in_source(requirement["ad_quote"], ad_text),
8799
"downgraded": downgraded,
100+
"downgrade_reason": downgrade_reason,
88101
"note": note,
89102
}
90103
)

0 commit comments

Comments
 (0)