hired.alignment#
JD-vs-candidate alignment: classify each requirement honestly into four buckets.
Public surface:
schemas in
hired.alignment.base(Requirement,RequirementRecord,AlignmentReport, and the enums),the deterministic rubric in
hired.alignment.rubric(classify(),assign_bucket(),apply_ai_leverage()),the elicitation helpers in
hired.alignment.elicitation(rank_clarifications(),is_decision_stable()),calibrated confidence in
hired.alignment.calibration(semantic_consistency(),calibrate_match()and its conformalMatchCalibratorask/auto-decide rule),deterministic report finalization in
hired.alignment.assemble(finalize_report()— reclassify, recount, rebuild blockers/clarifications),the injected-LLM analyzer in
hired.alignment.analyzer(LLMAlignmentAnalyzer,analyze_jd()— decompose, retrieve, quote-then-answer, grounding gate, deterministicaggregate_verdict()),rendering in
hired.alignment.report(render_report()dispatching torender_report_markdown()/render_report_html()).
The intelligence (judging transfer distance, trainability, evidence) is supplied
by the hired-align skill (Claude as brain) or an injected LLM; this package
provides the schemas, deterministic scoring, and rendering. See
misc/docs/DESIGN.md §6-8.
Functions
|
Fill |
|
Assign the alignment bucket for a record, or |
|
Soften a codified gap's closeability by the candidate's AI leverage. |
|
Residual gap, floored at zero. |
|
Produce clarifying questions for askable records, highest info-gain first. |
|
True when no remaining open unknown could flip the verdict. |
|
Whether to route this record to a clarifying question. |
|
Expected information gain of resolving this requirement, wrt the verdict. |
|
The agreement of sampled answers, clustered by |
|
The share of sampled judgments that say "match": a score in |
|
A |
|
Fit the ask/auto-decide rule on held-out judgments with known truth. |
|
Set |
|
Return a copy of |
|
True for a gate-keeper requirement that is a hard gap or contradicted. |
|
Render |
|
Render the report as a Markdown string. |
|
Render the report as a self-contained HTML page (inline CSS, no assets). |
|
Return a structured diff of two alignment-report dicts. |
|
A short human-readable summary of |
|
Analyse |
|
The verdict and fit band, computed from classified records alone. |
|
|
|
The |
|
A semantic |
|
An |
|
True when |
Classes
|
One atomic requirement extracted verbatim from a job description. |
|
The analysis of one requirement against the candidate's knowledge. |
|
A verbatim grounding span for a match judgment. |
|
A complete, verdict-first alignment analysis for one JD. |
|
|
|
|
|
|
|
A question to ask the candidate to resolve a decision-relevant unknown. |
|
|
|
The four alignment buckets. |
|
How the candidate's background relates to the requirement (Axis A). |
|
How decision-critical a requirement is. |
|
|
|
How hard a gap is to close (Axis B), after the AI-leverage modifier. |
|
|
|
|
|
|
|
How much the candidate's standing AI-agent capability lowers the ramp. |
|
Local closed-world flag: may a missing value be read as a real negative? |
|
|
|
|
|
How far several sampled answers to one question agree. |
|
A fitted class-conditional conformal rule over a match score |
|
What to do with a judgment: take it as a match, as no match, or ask. |
|
Draft an alignment report from JD text and facts, with an injected LLM. |
- class hired.alignment.AILeverage(*values)[source]#
-
How much the candidate’s standing AI-agent capability lowers the ramp.
Applies to codified / knowledge-breadth gaps, not tacit-judgment or enduring-aptitude gaps (those it cannot rescue).
- class hired.alignment.AlignmentReport(*, job_id, job_title='', company='', created_at='', verdict, score_summary=<factory>, requirements=<factory>, blocking_gaps=<factory>, next_actions=<factory>, interview_prep=<factory>, clarifications=<factory>)[source]#
Bases:
BaseModelA complete, verdict-first alignment analysis for one JD.
- class hired.alignment.Clarification(*, requirement_id, question, fills_field='', reason='', info_gain=0.0)[source]#
Bases:
BaseModelA question to ask the candidate to resolve a decision-relevant unknown.
- class hired.alignment.Closeability(*values)[source]#
-
How hard a gap is to close (Axis B), after the AI-leverage modifier.
- class hired.alignment.Consistency(majority, agreement, entropy, n_samples, counts=dict())[source]#
Bases:
objectHow far several sampled answers to one question agree.
majorityis the most common meaning (Nonewithout samples),agreementits share,entropythe Shannon entropy of the meanings normalised to[0, 1](0: all agree; 1: spread evenly over the meanings found),countsthe number of samples per meaning.
- class hired.alignment.Decision(*values)[source]#
-
What to do with a judgment: take it as a match, as no match, or ask.
- class hired.alignment.Evidence(*, quote, source_document_id='', locator='')[source]#
Bases:
BaseModelA verbatim grounding span for a match judgment.
- class hired.alignment.FieldCompleteness(*values)[source]#
-
Local closed-world flag: may a missing value be read as a real negative?
- class hired.alignment.InterviewPrep(*, summary='', talking_points=<factory>, story_library=<factory>, proactive_disclosure='')[source]#
Bases:
BaseModel
- class hired.alignment.LLMAlignmentAnalyzer(*, model='gpt-4o-mini', client=None, api_key=None, n_samples=1, temperature=None, calibrator=None, retrieve=<function retrieve_facts>, top_k=5, nli=False, entails=None)[source]#
Bases:
objectDraft an alignment report from JD text and facts, with an injected LLM.
n_samples> 1 judges each requirement several times and feeds the agreement intoapply_calibration()(withcalibrator, the conformal ask/auto-decide rule).nliadds an entailment check on every confirmed quote;entailsreplaces the default (an LLM call) with any(premise, hypothesis) -> bool.retrievereplaces the lexicalretrieve_facts(), e.g. withmake_embedding_retriever()for semantic retrieval.>>> class _Fake: ... class chat: ... class completions: ... @staticmethod ... def create(**_): ... >>> LLMAlignmentAnalyzer(client=_Fake()).analyze(jd_text, facts)
- analyze(jd_text, facts, *, job_id='job', job_title='', company='', requirements=None)[source]#
A draft report: decompose (unless
requirementsgiven), judge, aggregate.- Return type:
- class hired.alignment.MatchCalibrator(match_threshold, no_match_threshold, false_accept_rate=0.05, miss_rate=0.1, n_match=0, n_no_match=0)[source]#
Bases:
objectA fitted class-conditional conformal rule over a match score
sin[0, 1].“Match” stays in the prediction set while its nonconformity
1 - sis at mostmatch_threshold; “no match” whilesis at mostno_match_threshold. A singleton set decides; two labels (or none) mean ask. JSON-ready throughto_dict()/from_dict(), so a fitted rule can be stored and reviewed.
- class hired.alignment.MatchType(*values)[source]#
-
How the candidate’s background relates to the requirement (Axis A).
- class hired.alignment.NextAction(*, action, addresses='', priority=1, expected_effect='')[source]#
Bases:
BaseModel
- class hired.alignment.Requirement(*, id=<factory>, text, skill_type=SkillType.TECHNICAL, requirement_class=RequirementClass.DIFFERENTIATOR, required_level=3)[source]#
Bases:
BaseModelOne atomic requirement extracted verbatim from a job description.
- class hired.alignment.RequirementRecord(*, requirement, match_state=MatchState.UNKNOWN, field_completeness=FieldCompleteness.OPEN, bucket=None, match_type=MatchType.NONE, candidate_level=0, gap_size=0, source_skill=None, adjacency_basis=None, transferability=None, closeability=None, close_method=None, time_to_close=None, ai_leverage=AILeverage.NONE, confidence=ConfidenceLevel.LOW, uncertainty_reason=None, evidence=None, match_score=None, calibrated_decision=None, impact=3, info_gain=0.0, needs_clarification=False, talking_point=None)[source]#
Bases:
BaseModelThe analysis of one requirement against the candidate’s knowledge.
- class hired.alignment.ScoreSummary(*, fit_band=FitBand.FAIR, bucket_counts=<factory>, ats_readability=None)[source]#
Bases:
BaseModel
- class hired.alignment.Verdict(*, recommendation, confidence=ConfidenceLevel.MEDIUM, confidence_basis='', headline='', key_reasons=<factory>, has_blocking_gaps=False)[source]#
Bases:
BaseModel
- hired.alignment.aggregate_verdict(records, *, apply_at=0.7, stretch_at=0.4, fit_bands=((0.85, FitBand.GREAT), (0.7, FitBand.GOOD), (0.5, FitBand.FAIR), (0.3, FitBand.WEAK), (0.0, FitBand.POOR)), class_weights={RequirementClass.DIFFERENTIATOR: 2.0, RequirementClass.GATE_KEEPER: 3.0, RequirementClass.VALUE_ADD: 1.0}, bucket_credit={Bucket.ADJACENT_TRANSFERABLE: 0.5, Bucket.GAP_HARD: 0.0, Bucket.GAP_LEARNABLE: 0.25, Bucket.STRONG_MATCH: 1.0})[source]#
The verdict and fit band, computed from classified records alone.
A blocking gap (a gate-keeper that is a hard gap or contradicted) means do not apply; otherwise the weighted coverage picks the recommendation. Confidence comes from how much of the JD is resolved, not from the LLM.
>>> from hired.alignment.base import MatchType >>> rec = classify(RequirementRecord(requirement=Requirement(text='Python'), ... match_state='confirmed', match_type=MatchType.DIRECT, candidate_level=4)) >>> verdict, band = aggregate_verdict([rec]) >>> verdict.recommendation.value, band.value, verdict.confidence.value ('apply', 'great', 'high')
- hired.alignment.analyze_jd(workspace, jd_text, *, job_id, job_title='', analyzer=None, requirements=None)[source]#
Analyse
jd_textagainst the workspace candidate’s facts and persist it.The draft goes through
JDWorkspace.save_alignment()(finalize + archive + save), the one path from a draft to a stored report.analyzerdefaults to anLLMAlignmentAnalyzeron theaiextra.- Return type:
- hired.alignment.apply_ai_leverage(closeability, ai_leverage, *, skill_type, is_tacit=False)[source]#
Soften a codified gap’s closeability by the candidate’s AI leverage.
Tacit/soft gaps and structurally-hard gaps are never softened — AI agents extend breadth of codified knowledge, not judgment or enduring aptitude.
>>> apply_ai_leverage(Closeability.REQUIRES_EXPERIENCE, AILeverage.HIGH, ... skill_type=SkillType.TECHNICAL) <Closeability.LEARNABLE: 'learnable'> >>> apply_ai_leverage(Closeability.REQUIRES_EXPERIENCE, AILeverage.HIGH, ... skill_type=SkillType.SOFT_SKILL) <Closeability.REQUIRES_EXPERIENCE: 'requires_experience'>
- Return type:
- hired.alignment.apply_calibration(record, samples, *, calibrator=None, meaning=None, is_match=None)[source]#
Set
record’s confidence from sampled judgments, and its decision if calibrated.samplesare several independent judgments of the same requirement (match states, by default). The record’sconfidencebecomesconfidence_level()of their agreement and itsmatch_scorematch_share(); with acalibrator,calibrated_decisionis itsdecide(), whichshould_ask()honours (without one it is cleared: new samples supersede an old decision, so re-apply, or clear it, once an answer settles the requirement). The match state stays the analyst’s: an ask questions a claim, it does not overturn it. Returns the record, changed in place.>>> from hired.alignment.base import Requirement >>> rec = RequirementRecord(requirement=Requirement(text="Kafka"), match_state="confirmed") >>> rec = apply_calibration(rec, ["confirmed", "confirmed", "unknown"]) >>> rec.confidence.value, round(rec.match_score, 2), rec.calibrated_decision ('medium', 0.67, None)
- Return type:
- hired.alignment.assign_bucket(record)[source]#
Assign the alignment bucket for a record, or
Noneif it should be a clarifying question instead.Returns
Nonewhen the requirement isUNKNOWNon an OPEN field — that routes to elicitation rather than being scored as a gap (the “don’t assume absence” rule).UNKNOWNon a CLOSED field is treated as a real gap.
- hired.alignment.calibrate_match(scores, labels, *, false_accept_rate=0.05, miss_rate=0.1)[source]#
Fit the ask/auto-decide rule on held-out judgments with known truth.
scoresare match scores in[0, 1](saymatch_share()of sampled judgments),labelswhether each was truly a match. Each class gets its own threshold (Mondrian split conformal):false_accept_ratebounds how often a true non-match is auto-accepted,miss_ratehow often a true match is auto-rejected. Keep the held-out set apart from anything used to tune the scoring, or the bound does not hold.- Return type:
- hired.alignment.classify(record)[source]#
Fill
gap_sizeandbucket(andneeds_clarification) in place.Returns the same record for convenience.
- Return type:
- hired.alignment.compute_gap_size(required_level, candidate_level)[source]#
Residual gap, floored at zero.
- Return type:
- hired.alignment.confidence_level(agreement, *, high=0.9, medium=0.6)[source]#
A
ConfidenceLevelfrom sampled agreement rather than self-report.>>> confidence_level(0.95), confidence_level(0.7), confidence_level(0.5) (<ConfidenceLevel.HIGH: 'high'>, <ConfidenceLevel.MEDIUM: 'medium'>, <ConfidenceLevel.LOW: 'low'>)
- Return type:
- hired.alignment.coverage(records, *, class_weights={RequirementClass.DIFFERENTIATOR: 2.0, RequirementClass.GATE_KEEPER: 3.0, RequirementClass.VALUE_ADD: 1.0}, bucket_credit={Bucket.ADJACENT_TRANSFERABLE: 0.5, Bucket.GAP_HARD: 0.0, Bucket.GAP_LEARNABLE: 0.25, Bucket.STRONG_MATCH: 1.0})[source]#
(coverage, resolved_share): weighted bucket credit over resolved records, and the weighted share of records that are resolved at all.Records must be classified (see
classify()).
- hired.alignment.diff_reports(old, new)[source]#
Return a structured diff of two alignment-report dicts.
Both inputs are
AlignmentReport.model_dump()dicts. The result has:verdict_changed/verdict_old/verdict_newfit_old/fit_newbucket_changes: list of{requirement, from, to}for requirements whose bucket moved (the heart of a refresh — typically UNKNOWN→known as Q&A resolves false negatives)added/removed: requirement texts present in only one versionclarifications_resolved: clarifying questions in old but not new
- hired.alignment.finalize_report(report)[source]#
Return a copy of
reportwith every derivable field recomputed.Clarifications and flagged blockers refer to requirements by
id; give requirements explicit ids in a draft so those links survive (flagged blockers also fall back to matching by requirement text).>>> from hired.alignment import (AlignmentReport, Requirement, RequirementRecord, ... RequirementClass, Verdict, Recommendation, MatchType, Closeability) >>> from hired.candidate.base import MatchState >>> gate = Requirement(id='r1', text='PhD', requirement_class=RequirementClass.GATE_KEEPER) >>> recs = [ ... RequirementRecord(requirement=gate, closeability=Closeability.STRUCTURALLY_HARD, ... match_state=MatchState.CONTRADICTED), ... RequirementRecord(requirement=Requirement(id='r2', text='Python', required_level=3), ... match_state=MatchState.CONFIRMED, match_type=MatchType.DIRECT, ... candidate_level=5), ... ] >>> report = finalize_report(AlignmentReport( ... job_id='ds', verdict=Verdict(recommendation=Recommendation.STRETCH), ... requirements=recs)) >>> report.score_summary.bucket_counts['strong_match'] 1 >>> [r.requirement.id for r in report.blocking_gaps], report.verdict.has_blocking_gaps (['r1'], True)
- Return type:
- hired.alignment.info_gain(record)[source]#
Expected information gain of resolving this requirement, wrt the verdict.
Heuristic:
uncertainty × criticality. Animpactoverride (1-5) scales criticality when the analyst has a sharper view than the requirement class.- Return type:
- hired.alignment.is_blocking(record)[source]#
True for a gate-keeper requirement that is a hard gap or contradicted.
- Return type:
- hired.alignment.is_decision_stable(records)[source]#
True when no remaining open unknown could flip the verdict.
Concretely: there are no askable (decision-relevant, open, unknown) requirements left. This is the sharpest stop criterion from the research.
- Return type:
- hired.alignment.make_embedding_retriever(embed=None, *, min_similarity=0.0)[source]#
A semantic
retrieveforLLMAlignmentAnalyzer: thekfacts most cosine-similar to the requirement, so adjacent skills (RabbitMQ for a Kafka requirement) reach the judge.embedmaps texts to vectors (defaultopenai_embed(), theaiextra). Fact vectors are cached by text, so each fact is embedded once per retriever.>>> vocab = ('kafka', 'rabbitmq', 'queue', 'french') >>> def embed(texts): # a fake: 'kafka' and 'rabbitmq' are both message queues ... return [[t.lower().count(w) + ('queue' == w) * ('kafka' in t.lower() or ... 'rabbitmq' in t.lower()) for w in vocab] for t in texts] >>> fs = [Fact(statement='Ran RabbitMQ in prod'), Fact(statement='Speaks French')] >>> retrieve = make_embedding_retriever(embed) >>> [f.statement for f in retrieve(Requirement(text='Kafka'), fs, k=1)] ['Ran RabbitMQ in prod']
The share of sampled judgments that say “match”: a score in
[0, 1].By default a sample matches when it is (or names)
MatchState.CONFIRMED;is_matchoverrides that. This is the scorecalibrate_match()takes.>>> match_share(["confirmed", "confirmed", "unknown", "contradicted"]) 0.5
- Return type:
- hired.alignment.openai_embed(*, client=None, model='text-embedding-3-small')[source]#
An
Embedover OpenAI-styleclient.embeddings.create(aiextra).openaiis imported, and the client made, only at the first call.
- hired.alignment.quote_is_grounded(quote, fact, *, min_words=2)[source]#
True when
quoteis a verbatim span (modulo case/whitespace) offact, at leastmin_wordslong.>>> quote_is_grounded('kafka CLUSTERS', Fact(statement='Ran Kafka clusters')) True >>> quote_is_grounded('Kafka expert', Fact(statement='Ran Kafka clusters')) False >>> quote_is_grounded('Kafka', Fact(statement='Ran Kafka clusters')) False
- Return type:
- hired.alignment.rank_clarifications(records, *, max_questions=None, min_info_gain=0.0)[source]#
Produce clarifying questions for askable records, highest info-gain first.
The question text is left to the analyst; this returns the prioritized skeleton (requirement, reason, info_gain) so the caller can fill
question.- Return type:
- hired.alignment.render_report(report, fmt='markdown')[source]#
Render
report(a model or its JSON dict) in the named format.>>> from hired.alignment import AlignmentReport, Verdict, Recommendation >>> r = {'job_id': 'ds', 'verdict': {'recommendation': 'apply'}} >>> render_report(r).splitlines()[0] '# Alignment: ds' >>> render_report(r, 'pdf') Traceback (most recent call last): ... ValueError: Unknown report format 'pdf'; choose from: html, markdown, md
- Return type:
- hired.alignment.render_report_html(report)[source]#
Render the report as a self-contained HTML page (inline CSS, no assets).
>>> from hired.alignment import AlignmentReport, Verdict, Recommendation >>> page = render_report_html(AlignmentReport(job_id='ds', company='Acme <Inc>', ... verdict=Verdict(recommendation=Recommendation.APPLY, headline='Go'))) >>> page.startswith('<!doctype html>'), 'Acme <Inc>' in page (True, True)
- Return type:
- hired.alignment.render_report_markdown(report)[source]#
Render the report as a Markdown string.
- Return type:
- hired.alignment.retrieve_facts(requirement, facts, *, k=5, small_kb_passes_all=True)[source]#
The
kfacts sharing the most words with the requirement.Lexical, so it misses an adjacent skill named in different words (RabbitMQ for Kafka). When the whole knowledge base fits in
k(andsmall_kb_passes_all), every fact is passed, best overlap first, so the judge sees the adjacent skill anyway; a negation fact sharing no word is still dropped, so an unrelated “does not …” cannot back a contradiction. Otherwise facts sharing no word are dropped (none if none do). For large KBs, injectmake_embedding_retriever().>>> from hired.candidate.base import Fact >>> fs = [Fact(statement='Ran Kafka clusters'), Fact(statement='Speaks French')] >>> [f.statement for f in retrieve_facts(Requirement(text='Kafka streaming'), fs)] ['Ran Kafka clusters', 'Speaks French'] >>> [f.statement for f in retrieve_facts(Requirement(text='Kafka streaming'), fs, k=1)] ['Ran Kafka clusters']
- hired.alignment.semantic_consistency(samples, *, meaning=None)[source]#
The agreement of sampled answers, clustered by
meaning(default: equality).meaningmaps an answer to its meaning: a normalised label, an entailment cluster id. Answers that mean the same count as agreeing however worded.>>> c = semantic_consistency(["Yes", "yes", "no", "YES "], meaning=lambda s: s.strip().lower()) >>> c.majority, c.agreement, round(c.entropy, 3) ('yes', 0.75, 0.811) >>> semantic_consistency([]).agreement 0.0
- Return type:
- hired.alignment.should_ask(record)[source]#
Whether to route this record to a clarifying question.
Ask only when it’s
UNKNOWNon an OPEN field and decision-relevant — the “don’t assume absence from silence” rule. CONTRADICTED facts and closed-field unknowns are real gaps, not questions. A decision-relevant CONFIRMED or CONTRADICTED record whose calibrated decision is ask (sampled judgments too inconsistent for the conformal rule, seehired.alignment.calibration) is asked about too: “never exaggerate” means a shaky match is confirmed first, and a shaky absence is not assumed. An UNKNOWN follows the rule above.- Return type:
- hired.alignment.summarize_diff(diff)[source]#
A short human-readable summary of
diff_reports()output.- Return type:
Modules
Library-mode autonomous alignment analysis, driven by an injected LLM. |
|
Deterministically finalize an analyst-drafted |
|
Schemas for JD-vs-candidate alignment analysis. |
|
Calibrated confidence: multi-sample consistency and a conformal ask/auto-decide rule. |
|
Collect held-out (score, truth) pairs from answered clarifications and fit a calibrator. |
|
Deterministic diff between two alignment reports. |
|
The honesty loop: rank unknowns into the most informative questions first. |
|
Render an |
|
Deterministic bucket assignment — the two-axis rubric in code. |