hired.candidate#
Candidate knowledge domain: accumulate open-world facts about a candidate.
The public facade is CandidateKnowledgeBase. Schemas (Fact,
QAEntry, Provenance, and the enums) live in
hired.candidate.base; document/Q&A ingest in hired.candidate.ingest.
See misc/docs/DESIGN.md §5.
Functions
|
True when there is uningested source/Q&A material — a refresh is warranted. |
|
Refresh |
|
A filesystem-safe, extension-less key from an arbitrary label. |
|
Validate, quote-check, and persist fact records; return persisted ids. |
|
Build a (not-yet-persisted) |
|
True if |
Classes
|
Accumulated, open-world knowledge about a single candidate (user-level). |
|
Reports, company research, interview-prep briefings, and parsed jobs for one engagement. |
|
One subject's dossier: an |
|
The candidate-info refresh ledger (persisted to |
|
What we know about one raw source for change detection + provenance. |
|
One unit of pending work for a refresh: a changed source or an undistilled Q&A. |
|
Proposed fact records for one item (returned when |
|
Outcome (or preview) of a refresh. |
|
One atomic claim about a candidate. |
|
One clarifying question asked of the candidate and their answer. |
|
Where a fact came from, with an optional verbatim supporting quote. |
|
Coarse category for retrieval and synopsis grouping. |
|
Whether a fact is current or has been superseded by a newer one. |
|
Where a piece of provenance came from. |
|
Calibrated confidence in a claim (qualitative, not a raw probability). |
|
Three-valued epistemic state — the core of the honesty contract. |
- class hired.candidate.CandidateKnowledgeBase(user='me', *, store=None)[source]#
Bases:
objectAccumulated, open-world knowledge about a single candidate (user-level).
>>> import tempfile, os >>> os.environ['HIRED_DATA_DIR'] = tempfile.mkdtemp() >>> kb = CandidateKnowledgeBase() # default candidate "me" >>> from hired.candidate.base import Fact, FactCategory >>> _ = kb.add_fact(Fact(statement='Built ML pipelines in Python', ... category=FactCategory.SKILL, tags=['python', 'ml'])) >>> [f.statement for f in kb.facts(category=FactCategory.SKILL)] ['Built ML pipelines in Python'] >>> [f.statement for f in kb.facts(tags=['ml'])] ['Built ML pipelines in Python']
- add_note(subject, text=None, *, files=None)[source]#
Record volunteered info about a subject into its dossier.
textis appended to the dossier’soverview.md;files(a{name: bytes}mapping) are attached as detail/media. Returns the dossier. This is the “by the way, I also did X” entry point — a single sentence or a whole folder both land here.- Return type:
- add_source(src, *, name=None)[source]#
Store a raw source (file path or bytes) and record its content digest.
Returns the source key (its name in the raw store). The digest (in
state.json) lets a later refresh detect new/changed sources without re-reading everything. Facts extracted from a source cite it by this key.- Return type:
- facts(*, category=None, tags=None, status=FactStatus.ASSERTED, include_negations=True)[source]#
Iterate facts, optionally filtered by category/tags/status.
By default only
ASSERTEDfacts are returned (superseded ones are hidden).tagsmatches facts containing any of the given tags.
- jd(jd_id, *, company=None, label=None)[source]#
Get-or-create the workspace for an engagement (1+ JDs of one company).
company/labelare recorded in the engagement’smetawhen given.- Return type:
- needs_refresh()[source]#
True when uningested source/Q&A material exists (refresh warranted).
- Return type:
- record_qa(entry, *, derived_facts=None)[source]#
Append a clarifying Q&A exchange; optionally distill it into facts.
When
derived_facts(atomic fact records extracted from the answer) are given, they are ingested withSourceKind.QAprovenance (source_id= the Q&A id, quotes verified against the answer) and back-linked via the entry’sderived_fact_ids— so a Q&A answer becomes reusable, discoverable knowledge rather than being buried in the history.- Return type:
- refresh(mode='soft', *, ingest_fn=None, apply=True)[source]#
Refresh
infofrom changed sources + undistilled Q&A.ingest_fn(item)supplies extraction (intelligence is external); withapply=Falsethe result is a non-destructive preview. Seehired.candidate.refresh.- Return type:
- regenerate_synopsis()[source]#
Rebuild and persist a human-readable synopsis from current facts.
This is a projection — always derived from the fact store, never hand-edited — so it can be regenerated at any time without loss.
- Return type:
- save_upload(name, data)[source]#
Store a raw uploaded document by filename (see
add_source()).- Return type:
- supersede(old_fact_id, new_fact)[source]#
Replace
old_fact_idwithnew_fact(invalidate, don’t delete).- Return type:
- class hired.candidate.ConfidenceLevel(*values)[source]#
-
Calibrated confidence in a claim (qualitative, not a raw probability).
- class hired.candidate.Fact(**data)[source]#
Bases:
BaseModelOne atomic claim about a candidate.
Atomicity matters: a fact states a single thing so it can be confirmed, superseded, or cited independently.
- class hired.candidate.FactCategory(*values)[source]#
-
Coarse category for retrieval and synopsis grouping.
- class hired.candidate.FactStatus(*values)[source]#
-
Whether a fact is current or has been superseded by a newer one.
- class hired.candidate.JDWorkspace(kb, jd_id, *, store=None)[source]#
Bases:
objectReports, company research, interview-prep briefings, and parsed jobs for one engagement.
>>> import tempfile, os >>> os.environ['HIRED_DATA_DIR'] = tempfile.mkdtemp() >>> from hired.candidate import CandidateKnowledgeBase >>> kb = CandidateKnowledgeBase() >>> ws = kb.jd('acme', company='Acme, Inc.', label='Acme roles') >>> ws.save_report('staff-ds', {'verdict': {'recommendation': 'apply'}}) >>> ws.get_report('staff-ds')['verdict']['recommendation'] 'apply' >>> ws.meta['company'] 'Acme, Inc.'
- save_briefing(key, data)[source]#
Persist an interview-prep research briefing (keyed by subject/job).
- Return type:
- class hired.candidate.MatchState(*values)[source]#
-
Three-valued epistemic state — the core of the honesty contract.
UNKNOWNis distinct fromCONTRADICTED: we have not yet looked, so we must ask rather than assume absence.
- class hired.candidate.Provenance(**data)[source]#
Bases:
BaseModelWhere a fact came from, with an optional verbatim supporting quote.
- class hired.candidate.QAEntry(**data)[source]#
Bases:
BaseModelOne clarifying question asked of the candidate and their answer.
Q&A is append-only history; the distilled, updatable projection lives in
Factrecords (linked viaderived_fact_ids).
- class hired.candidate.RefreshItem(kind, key, content)[source]#
Bases:
objectOne unit of pending work for a refresh: a changed source or an undistilled Q&A.
- class hired.candidate.RefreshProposal(kind, key, records)[source]#
Bases:
objectProposed fact records for one item (returned when
apply=False).
- class hired.candidate.RefreshReport(mode, applied, pending=<factory>, proposals=<factory>, added_fact_ids=<factory>, superseded_fact_ids=<factory>)[source]#
Bases:
objectOutcome (or preview) of a refresh.
- class hired.candidate.RefreshState(**data)[source]#
Bases:
BaseModelThe candidate-info refresh ledger (persisted to
user/info/state.json).
- class hired.candidate.SourceDigest(**data)[source]#
Bases:
BaseModelWhat we know about one raw source for change detection + provenance.
- class hired.candidate.TopicDossier(base_dir, *, name=None)[source]#
Bases:
objectOne subject’s dossier: an
overview.mdplus optional attached files.>>> import tempfile, os >>> d = TopicDossier(os.path.join(tempfile.mkdtemp(), 'patents'), name='Patents') >>> d.add_note('Holds 3 US patents on anomaly detection.') >>> d.overview.splitlines()[0] '# Patents' >>> d.add_file('cert.txt', b'patent cert') >>> d.files() ['cert.txt'] >>> d.get_file('cert.txt') b'patent cert'
- hired.candidate.fact_from_record(record, *, source_kind, source_id='', subject='me')[source]#
Build a (not-yet-persisted)
Factfrom a record dict.- Return type:
- hired.candidate.ingest_facts(kb, records, *, source_kind, source_id='', source_text=None, drop_unverified_quotes=True)[source]#
Validate, quote-check, and persist fact records; return persisted ids.
When
source_textis given, each record’squoteis checked to be a verbatim substring. Unverified quotes are dropped (the fact is still kept, but without the spurious quote) unlessdrop_unverified_quotesis False, in which case aValueErroris raised — useful for strict pipelines.
- hired.candidate.needs_refresh(kb)[source]#
True when there is uningested source/Q&A material — a refresh is warranted.
- Return type:
- hired.candidate.refresh(kb, mode='soft', *, ingest_fn=None, apply=True)[source]#
Refresh
infofrom changed sources + undistilled Q&A. See module docstring.ingest_fn(item: RefreshItem) -> list[dict]supplies the extraction intelligence (records are the usual{"statement", "category", "quote", …}dicts). Withingest_fn=Nonethe report just lists the pending items (the caller does extraction). Withapply=Falsethe records are returned as proposals and nothing is written.- Return type:
- hired.candidate.slug(text)[source]#
A filesystem-safe, extension-less key from an arbitrary label.
Used to derive stable store keys from human labels (company names, subjects, briefing titles) so callers pass natural text and the store stays tidy.
- Return type:
>>> slug('Socure, Inc.') 'socure-inc' >>> slug('KYC / AML primer') 'kyc-aml-primer'
- hired.candidate.verify_quote(quote, source_text)[source]#
True if
quoteis a verbatim substring ofsource_text.A
Nonequote (no quote claimed) always verifies. When no source text is available to check against, we cannot disprove it, so it verifies too — the invariant only bites when we can check.- Return type:
Modules
Open-world, provenance-first schemas for accumulated candidate knowledge. |
|
Turn extracted atomic-fact records into persisted, provenance-bearing facts. |
|
The candidate knowledge base: a facade over the user-level store. |
|
Refresh bookkeeping: per-source content digests + last-refresh timestamps. |
|
Topic dossiers — "a little, or a whole lot" about any subject the candidate shares. |
|
The per-engagement facade: alignment reports, company research, interview prep. |