Skip to content

Commit b356fc7

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

46 files changed

Lines changed: 606 additions & 31 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,4 @@ design-preview/
115115

116116
# Thesis: practice-case runs are for trying the runner, never results
117117
thesis/results/practice*/
118+
thesis/results/stress*/

‎CLAUDE.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -898,8 +898,14 @@ Thesis baseline (November 2026):
898898
`mandatory_unverified`. The panel is titled "AI assessment: qualification fit" and
899899
says it does not judge job attractiveness or predict hiring. Practice cases p2, p4
900900
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`.
901+
criteria (Consider) is in `thesis/practice_cases/README.md`.
902+
- Prompt 7 (2026-11-24) after 10 formative stress cases (`thesis/stress_cases/`,
903+
unsupported negatives, misleading quotes, ambiguous requirements; plus 2 added for
904+
the fix): a list heading ("Requirements", "Krav") makes its bare items mandatory,
905+
a person-describing heading ("Vi tror att du") does not; a total of experience the
906+
CV itself states below half is always not_met (prompt 6 chose
907+
not_enough_information against its own note). Freeze tag `thesis-prototype-v3` on
908+
the merge of the stress-case PR. Stress and practice output is never committed.
903909
- Removed before the baseline: the unused `POST /api/v1/ai/tailor-cv`
904910
(`endpoints/ai.py`, `services/ai_service.py`). The `cv_analysis` label in
905911
`AdminAiCosts.tsx` stays, because old usage rows still carry that purpose.

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

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

44
from __future__ import annotations
55

6-
PROMPT_VERSION = "6"
6+
PROMPT_VERSION = "7"
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").
@@ -31,10 +31,15 @@
3131
- category: skill, experience, education, language, certification or other.
3232
- importance:
3333
- mandatory: the ad says it is required ("must", "required", "you have", \
34-
"we require", "krav", "ska ha", "vi kräver", "du har").
34+
"we require", "krav", "ska ha", "vi kräver", "du har"), in the item itself or \
35+
in the heading of the list it stands under ("Requirements", "Must have", \
36+
"Krav", "Vi kräver").
3537
- preferred: the ad says it is a plus ("nice to have", "a plus", \
36-
"preferably", "meriterande", "gärna", "det är ett plus").
37-
- unclear: the ad lists it without saying which. Do not guess.
38+
"preferably", "meriterande", "gärna", "det är ett plus"), in the item itself \
39+
or in the heading of its list ("Nice to have", "Meriterande").
40+
- unclear: neither the item nor its heading says which. A heading that only \
41+
describes the person ("About you", "Vi tror att du", "Om dig") does not say \
42+
which. Do not guess.
3843
- ad_quote: the phrase or sentence in the ad that states it, copied word for \
3944
word in the ad's own language. Never translate or reword a quote.
4045
@@ -90,19 +95,22 @@
9095
today's date. An internship counts for its actual length. University projects \
9196
and thesis work show experience with a tool or method but add no work time. \
9297
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.
98+
none). In the note, write the total in months, say whether the CV states \
99+
that total itself or you added it up from the periods it lists, then the \
100+
amount asked in months and half of that amount, for example "Total 8 months, \
101+
added up from the listed periods; asked 12 months; half is 6 months." or \
102+
"Total 6 months, stated by the CV; asked 36 months; half is 18 months." Then:
103+
- met: the total is equal to or more than the amount asked.
104+
- partly_met: the total is less than the amount asked but at least half of it.
105+
- not_met: the CV itself states the person's total relevant experience (for \
106+
example "6 months of professional experience in total"), or states that they \
107+
have no other relevant work, and that total is less than half of the amount \
108+
asked. Quote that statement. A total stated by the CV that is below half is \
109+
always not_met, never not_enough_information.
110+
- not_enough_information: a total you added up from the listed periods that \
111+
is below half, and work periods without dates. The jobs a CV lists are not \
112+
necessarily all the work a person has done, so a short added-up total does \
113+
not show that the person's total is short.
106114
107115
Today's date is given with the CV. An education or job is completed when its \
108116
end date is before today. When only a year is given, treat it as completed if \

‎backend/tests/test_fit_advisor_service.py‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,35 @@ def test_the_evidence_prompt_no_longer_treats_absence_as_a_mismatch() -> None:
492492
together.
493493
"""
494494
text = prompts.EVIDENCE_PROMPT
495-
assert prompts.PROMPT_VERSION == "6"
495+
assert prompts.PROMPT_VERSION == "7"
496496
assert "a CV normally" not in text and "normally lists" not in text
497497
assert "always lists the jobs" not in text
498498
assert "never not_met only because the CV does not mention it" in text
499499
assert "Required for met, partly_met and not_met" in text
500500
for silent in ("driving licence", "work permit", "language level", "willingness to travel"):
501501
assert silent in text.split("not_enough_information: the CV does not settle it")[1]
502502
assert "states the person's total relevant experience" in text
503-
assert "a short documented period does not show that the total is short" in text
503+
assert "a short added-up total does not show that the person's total is short" in text
504+
# Prompt 7 (stress case s09): a stated total below half is not_met, said outright,
505+
# and the note must say whether the total is stated or added up.
506+
assert "A total stated by the CV that is below half is always not_met" in text
507+
assert "say whether the CV states that total itself or you added it up" in text
504508
assert "half of the amount asked" in text # the half rule itself is unchanged
505509
assert "An education or job is completed when its end date is before today" in text
506510
assert "is never not_met in that case" in text # experience without a number
511+
512+
513+
def test_the_requirements_prompt_reads_list_headings() -> None:
514+
"""Prompt 7 (stress case s08): items under a "Requirements" heading are
515+
mandatory; a heading that only describes the person decides nothing."""
516+
text = prompts.REQUIREMENTS_PROMPT
517+
mandatory = text.split("- mandatory:")[1].split("- preferred:")[0]
518+
preferred = text.split("- preferred:")[1].split("- unclear:")[0]
519+
unclear = text.split("- unclear:")[1].split("- ad_quote:")[0]
520+
for heading in ('"Requirements"', '"Must have"', '"Krav"', '"Vi kräver"'):
521+
assert heading in mandatory
522+
for heading in ('"Nice to have"', '"Meriterande"'):
523+
assert heading in preferred
524+
for heading in ('"About you"', '"Vi tror att du"', '"Om dig"'):
525+
assert heading in unclear
526+
assert "Do not guess" in unclear

‎backend/tests/test_thesis_eval.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ def test_practice_cases_load() -> None:
8585
assert len(cases[2].expected_missing) == 2
8686

8787

88+
def test_stress_cases_load_and_cover_the_three_weak_points() -> None:
89+
cases = load_cases(REPO / "thesis" / "stress_cases", load_protocol(PROTOCOL_PATH))
90+
assert len(cases) == 12
91+
assert {c.reference for c in cases} == {"high_priority", "consider", "low_priority"}
92+
assert {c.language for c in cases} == {"en", "sv"}
93+
# Kept apart from the held-out cases: no stress case is in thesis/cases.
94+
held_out = REPO / "thesis" / "cases"
95+
assert not any((held_out / c.id).exists() for c in cases)
96+
97+
8898
def test_case_problems_are_all_reported(tmp_path: Path) -> None:
8999
_write_case(tmp_path, "a", "scenario: nonsense\nlanguage: en\nreference: maybe\n")
90100
_write_case(

‎thesis/DESIGN.md‎

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Design: AI-assisted job-fit assessment
22

33
Status: **design v1, decisions made on 2026-11-13** (section 10), built and tagged as
4-
`thesis-prototype-v1` and `-v2`. **Revised on 2026-11-24: prompt version 6, rules
5-
version 2** (decisions Q1 revised, Q9 and Q10). Changes after design v1 are recorded
4+
`thesis-prototype-v1` and `-v2`. **Revised on 2026-11-24: prompt version 7, rules
5+
version 2** (decisions Q1 revised, Q9 and Q10; prompt 7 after the stress cases). Changes after design v1 are recorded
66
in `DESIGN_LOG.md`.
77

88
This is activity 2 ("define the objectives for a solution") and the design half of
@@ -121,9 +121,13 @@ For each requirement the model returns:
121121
How importance is decided:
122122

123123
- **mandatory:** the ad says so ("must", "required", "you have", "krav", "ska ha",
124-
"vi kräver").
125-
- **preferred:** the ad says so ("nice to have", "a plus", "meriterande", "gärna").
126-
- **unclear:** the ad lists it without saying either.
124+
"vi kräver"), in the item or in the heading of its list ("Requirements", "Must have",
125+
"Krav", "Vi kräver"). The heading counts since prompt version 7: bare items under
126+
"Requirements" were read as unclear (stress case `s08`).
127+
- **preferred:** the ad says so ("nice to have", "a plus", "meriterande", "gärna"), in
128+
the item or in its heading ("Nice to have", "Meriterande").
129+
- **unclear:** neither the item nor its heading says either. A heading that only
130+
describes the person ("About you", "Vi tror att du", "Om dig") does not say.
127131

128132
### Step 2: evidence from the CV
129133

@@ -159,12 +163,14 @@ observation that language models and human screeners can differ in what they inf
159163
from a CV (Vaishampayan et al., 2025). These works motivate the rule; they did not test
160164
it.
161165

162-
**Stated amounts of experience** (version 5, revised in version 6): the work periods the
163-
CV documents are added up, an internship counting for its length and a running job up to
164-
the reference date. At least the amount asked is met; at least half of it is partly met.
166+
**Stated amounts of experience** (version 5, revised in versions 6 and 7): the work periods
167+
the CV documents are added up, an internship counting for its length and a running job up
168+
to the reference date. At least the amount asked is met; at least half of it is partly met.
165169
Below half is `not_met` **only when the CV itself states the total** (for example "6
166170
months of professional experience in total") or states that there is no other relevant
167-
work. A dated history of jobs and internships does not establish the person's complete
171+
work; such a stated total below half is always `not_met` (version 7: in version 6 the model
172+
wrote that the stated total was below half and still chose "not enough information",
173+
stress case `s09`). The note says whether the total is stated or added up. A dated history of jobs and internships does not establish the person's complete
168174
experience: the jobs a CV lists are not necessarily all the work a person has done. So a
169175
documented period below half, without such a statement, is `not_enough_information`. The
170176
half-way boundary is unchanged from version 5; it is a formative design convention, not

‎thesis/DESIGN_LOG.md‎

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ the search for a working design (Hevner et al., 2004, guideline 6) stays visible
1212
| 2026-11-13 | 4 | 1 | The user message states the year in plain words before and after the CV: "Any study or job period in the CV that ends in 2026 or earlier has ended." (the year is filled in by code). | All four practice cases give the expected recommendation, with identical requirement statuses in three runs each. Recommendations never changed across runs in any version; what changed was single requirement judgements. |
1313
| 2026-11-14 | 5 | 1 | Made after the freeze tag `thesis-prototype-v1` and before any evaluation case was written. (a) A rule for a stated amount of work experience: add up the work periods in the CV; met when the total reaches the amount, partly met from half of it, not met below half or with no relevant work. (b) The judgement's fields are written in the order quote, note, status, and the note must state the numbers. (c) Silence about a driving licence, work permit, citizenship, language or travel is always "not enough information". (d) Experience of a kind of work asked without a number is never "not met" when a job, internship or project in the CV involved it. (e) A quote is one unbroken piece of the CV. Three practice cases added (p5 to p7). | The first assessment in the live app (a real ad asking for "at least 4 years in a similar role", a CV with internships) judged that requirement "not enough information" and gave Consider, against a rule-based score of 94; the quote the model offered was not in the CV. Version 4 had no rule for how far short is too short. See the iterations below. |
1414
| 2026-11-24 | 6 | 2 | (a) Missing CV evidence is no longer a mismatch: an unmentioned skill, tool, certification or qualification is `not_enough_information`; `not_met` needs CV words that show the mismatch; a shortfall in a stated amount of experience needs a total the CV states. (b) Code sets aside a `not_met` with no CV quote or one not in the CV, as it already did for `met`, and records `downgrade_reason`. (c) A mandatory requirement whose ad quote is not in the ad is unverified (fail closed when the check is missing) and cannot give Low or High: rule order R1, R4 (new), R2, R3. (d) The panel separates qualification fit from job attractiveness. Made after `thesis-prototype-v2`, before any evaluation case existed. | A methodology review found that Q1 let silence count as non-qualification, and that one unmet mandatory requirement gives Low, so the most consequential result could rest on no evidence; and that an invented or misquoted requirement still reached the rules. See "Prompt 6 / rules 2" below. |
15+
| 2026-11-24 | 7 | 2 | (a) Step 1: an item's importance can come from the heading of its list ("Requirements", "Krav" make bare items mandatory; "Nice to have", "Meriterande" preferred); a heading that only describes the person ("Vi tror att du", "About you") decides nothing. (b) Step 2: the note says whether a total of experience is stated by the CV or added up; a stated total below half is always `not_met`. Ten stress cases added (`thesis/stress_cases/`). | The first stress run on prompt 6 found that a CV stating "6 months of professional experience in total" against 3 years was judged "not enough information" in 5 of 5 runs, though the note itself said the total was below half (Low was unreachable for the one shortfall the design allows), and that bare items under "Requirements" were read as unclear. See "Prompt 7" below. |
1516

1617
### Prompt version 5: the iterations
1718

@@ -200,3 +201,79 @@ For this change, as recorded in this session on 2026-11-24:
200201
- **Verifiable from the repository:** the diff and this entry. **Recorded here only:**
201202
the decisions above and the practice-run figures (the run's output is kept outside
202203
the repository, as practice output always is).
204+
205+
## Prompt 7 (2026-11-24): stress cases
206+
207+
### Why
208+
209+
Ten formative stress cases (`thesis/stress_cases/`) were written to probe the three weak
210+
points that prompt 6 / rules 2 address. They cover unsupported negative judgements,
211+
misleading quotations in the CV and in the ad, and ambiguous requirements. Two of them are
212+
controls that must stay Low. The expected outcomes were written before any run. Like the
213+
practice cases, they are written by the developer and are not evaluation cases.
214+
215+
### First run: prompt 6 / rules 2
216+
217+
60 assessments, 0 failures. 9 of 10 cases gave the expected priority in 5 of 5 runs:
218+
219+
- **Unsupported negatives held:** an absent certificate beside a listed one (`s01`), a
220+
six-month dated history against two years (`s02`), and no work permit or Swedish stated
221+
(`s03`) were all `not_enough_information`. Nothing rested on the name or country.
222+
- **Misleading CV quotations held:** "The course required no prior experience with
223+
Kubernetes" was not used as a mismatch (`s04`, High). "Go" mentioned only about the
224+
team was not counted as met, and "I have not used Go myself" gave Low (`s05`).
225+
- **Misleading ad context held:** Kubernetes, Kafka and Scala, named only under "About
226+
us", were not extracted (`s06`, High).
227+
- **Ambiguity:** "Vi tror att du" items were `unclear` (`s07`, Consider). The unfinished
228+
degree gave Low (`s10`).
229+
- **Failure 1 (`s09`, control):** the CV states "6 months of professional experience in
230+
total" against 3 years. Every run wrote "the CV states 6 months ... less than half" in
231+
the note and then chose `not_enough_information`: Consider instead of Low. This is the
232+
failure seen before version 5, a status that contradicts its own note. Here it made the
233+
one experience shortfall the design accepts unreachable.
234+
- **Failure 2 (`s08`):** the three items under "Requirements" had no "must" or
235+
"required" and were read as `unclear`. The priority was right (Consider) for the wrong
236+
reason: an unclear requirement decides nothing, so a real failure listed this way would
237+
never give Low, and a full match never High.
238+
239+
### Change
240+
241+
- **Step 1:** headings count as importance markers, and person-describing headings do
242+
not.
243+
- **Step 2:** the note states whether a total is stated or added up, and "a total stated
244+
by the CV that is below half is always not_met".
245+
- **Not changed:** the rules (version 2), the schemas, the model, temperature and seed.
246+
- **New cases:** `s11` (bare items under "Requirements", unfinished degree: Low) and
247+
`s12` (bare items under "Krav", all shown: High), written before the prompt-7 run.
248+
249+
### Second run: prompt 7
250+
251+
| Cases | AI assessments | Expected priority in every run | Ad quotes found | CV quotes found |
252+
|---|---|---|---|---|
253+
| 12 stress cases | 60 | 12 of 12 | 240 of 240 | 175 of 175 |
254+
| 7 practice cases (and p1's two variants) | 41 | 7 of 7 against the v6 expectations | 231 of 231 | 153 of 154 |
255+
256+
- `s09` is now Low, with "Total 6 months, stated by the CV" in the note.
257+
- `s08`, `s11` and `s12` read their headed items as mandatory; `s07` stays `unclear`.
258+
- **Practice cases:** p2, p4 and p5 stay Consider; p1, p3, p6 and p7 are unchanged.
259+
- **The quote check fired on real output for the first time.** In one p5 run the model
260+
quoted "Skills\nSQL", a heading joined to its item, for "Strong knowledge of SQL". The
261+
check set it aside; the priority did not change.
262+
- **Run-to-run variation** remained only on preferred requirements: Azure in p7 and
263+
Power BI in `s10`, met or partly met.
264+
- **Cost:** 0.0108 USD per assessment.
265+
266+
### What the stress cases do not show
267+
268+
- **Untested rules:** no case made the model invent an ad quote, so R4 has still only
269+
been tested with a faked model. No case produced a `not_met` with a quote absent from the
270+
CV either.
271+
- **Not caught by code:** `s04` and `s06` passed because the model read them right. If it
272+
had used the misleading sentence, the found quote would have passed the literal check.
273+
- **Scale:** twelve cases, written by the developer, cannot show how often these errors
274+
occur on real ads and CVs.
275+
276+
### Versions
277+
278+
Prompt 7, rules 2, protocol 1, model `gpt-4o-2024-08-06`. Tag `thesis-prototype-v3` marks
279+
this version, the evaluation candidate.

0 commit comments

Comments
 (0)