Repository navigation
Contributing
Checked against v0.7.6 on November 13, 2026.
How to set up a development copy of Kestrel, run the checks, write tests, commit, and stay inside the project's hard rules. For how the code fits together, see Architecture overview.
The source is public under the PolyForm Noncommercial License 1.0.0 (LICENSE.md). The files that govern day-to-day work are CLAUDE.md (standing orders and hard rules), docs/DEVELOPERS.md (CLI and setup), and docs/RELEASING.md. AGENTS.md is an identical copy of CLAUDE.md for other coding tools; if you change one, change both.
Kestrel needs Python 3.12 exactly (requires-python = ">=3.12,<3.13" in pyproject.toml) and uv. CI installs the interpreter with uv python install 3.12 and then runs uv sync --extra dev (.github/workflows/ci.yml). The dev extra adds ruff, pytest, pytest-asyncio, pytest-xdist, respx and pyinstaller.
git clone https://github.com/distantsoil/Kestrelapp && cd Kestrelapp
uv sync --extra dev
uv run kestrel setup # guided first run; add --dry-run to print the steps only
uv run kestrel serve --open # web UI on the first free port from 8765
uv run python -m kestrel.desktop # or the desktop window, where a webview backend existsWithout a GPU, uv run kestrel setup --hosted configures a hosted provider under your own key instead of Ollama (docs/DEVELOPERS.md, "No GPU? Run everything hosted").
Keep development data away from a real install by pointing the data folder somewhere disposable. KESTREL_DATA_HOME overrides the per-OS location (kestrel/paths.py).
export KESTREL_DATA_HOME="$HOME/kestrel-dev-data"$env:KESTREL_DATA_HOME = "$HOME\kestrel-dev-data"Optional pieces that some tests and features need:
- A Chromium-based browser for PDF rendering. Edge, Chrome, or Playwright's Chromium all work;
uv run playwright install chromiuminstalls the last, andKESTREL_BROWSER_PATHnames an explicit executable (kestrel/docs/render.py). - The bundled in-process embedding model, which is never committed. Fetch it with
uv run python scripts/fetch_embed_model.py(kestrel/resources/embed_model/is git-ignored). - Ollama, only for work that touches a real local model.
Commands you will use while developing (all defined in kestrel/cli.py):
uv run kestrel doctor # full preflight; --quick skips the slow live probes
uv run kestrel db upgrade # apply Alembic migrations to the app database
uv run kestrel models build # create the derived num_ctx models in Ollama
uv run kestrel scan --all # run every enabled source
uv run kestrel run # Tier 0, then drain Tier 1, then Tier 2
uv run kestrel evaluate 42 # push one opportunity through both tiers
uv run kestrel bench --help # compare models on the gold setOne script runs what CI runs (scripts/check.py). Run it before every push.
uv run --extra dev python scripts/check.py # the full check, before a push
uv run --extra dev python scripts/check.py --fast # lint, static checks and the whole suite, no coverage or browser stage
uv run --extra dev python scripts/check.py --quick # lint, static checks and the packaging and notices tests
uv run --extra dev python scripts/check.py --workers 0 # the full check, seriallyThe script does this, in order, and stops at the first failure:
ruff check .- The static checks on the branch's changes: new pyright errors in changed files, changed-line lint, the test floor, protected paths and test quality. Testing lists each rule.
-
pytest -q -rs -p no:cacheprovider -n <workers> --dist worksteal --max-worker-restart 0withKESTREL_HEADLESS=1set, which is the same environment CI uses. The suite runs in parallel with pytest-xdist.<workers>is--workers N, elseKESTREL_TEST_WORKERS, else half the CPUs capped at 8 with a minimum of 1, and--workers 0runs serially. The full suite includes the workflow, installer-script, third-party-notice and outbound-call guards (tests/test_packaging.py,tests/test_notices.pyandtests/test_outbound_inventory.py). - A skip report. If browser tests were skipped because no browser was found, it warns that the UI and PDF gates did not run. The opt-in UI tests, gated by
KESTREL_LIVE_BROWSER=1, are listed in the report but not warned about. - The full check only: the browser test files for the pages the branch touches, diff coverage of at least 80 percent for changed lines under
kestrel/, and a red-first proof for eachfix:commit that changes tests.
It ends with "Ready to push." when everything passed. --quick and --fast are for iterating, and each ends with a line that says to run the full check before pushing. The script runs ruff check only; it does not run ruff format. The ruff settings are in pyproject.toml: line length 100, target Python 3.12, rule groups E, F, I, UP, B and W.
To make git push run the full check automatically, opt in once per clone:
git config core.hooksPath .githooksThe hook is .githooks/pre-push. git push --no-verify skips it, and the hook's own comment reserves that for emergencies.
The full check runs the browser tests for the pages your branch touches. To run one page's tests by hand, use KESTREL_LIVE_BROWSER=1 with that page's tests/test_*_browser.py file, and the whole set when the change touches the shell or anything every page loads. Testing lists the gates in order.
Tests live in tests/. asyncio_mode = "auto" is set in pyproject.toml, so async def test_... functions need no marker. Run one file or one test while you work:
uv run pytest tests/test_queue.py -q
uv run pytest tests/test_docselect.py -q -k hallucinatedConventions the suite relies on:
- Write tests alongside the code, not after it (
CLAUDE.md). - Never call a live job board, ATS or SEC endpoint from a test. HTTP is mocked with
respx. Fixtures are captured payloads with identifying data replaced, stored intests/fixtures/(for examplegreenhouse.json,lever.json,workday_list.json). - Each test gets its own empty data folder through an autouse fixture in
tests/conftest.py, so nothing touches real app data. Thesmfixture gives a freshly migrated SQLite database per test, built by the real migrations. - Fake the model, not the pipeline.
tests/pipeline_fakes.pyis a deterministic fake LLM that returns schema-valid or deliberately invalid JSON depending on a marker such as[KILL]or[QUAR1]in the opportunity text. - Do not read the clock at import time in a test module.
tests/test_test_hygiene.pyfails if you do. - An unhandled exception in a background thread fails the test (
filterwarningsinpyproject.toml). - Tests that need a real browser skip themselves when none is found.
scripts/check.pyprints every skip reason. The UI tests that drive a page (tests/test_*_browser.pyand a few others) run only withKESTREL_LIVE_BROWSER=1, which the full check sets for the files of the pages a branch touches. Use the helpers intests/browser.py(launch,wait_for_layout, the page leak test) rather than launching Playwright yourself. - A new page script starts nothing at top level and passes the page leak test. See Adding a page.
- A new web address in the shipped code goes in the host index of
docs/OUTBOUND-CALLS.mdin the same change, ortests/test_outbound_inventory.pyfails.
A typical adapter test, trimmed from tests/test_greenhouse_adapter.py:
_FIXTURE = json.loads((Path(__file__).parent / "fixtures" / "greenhouse.json").read_text())
@respx.mock
async def test_greenhouse_adapter_field_mapping():
respx.get("https://boards-api.greenhouse.io/v1/boards/meridian/jobs").mock(
return_value=Response(200, json=_FIXTURE)
)
s = get_settings().ingest
async with HttpClient(user_agent=s.user_agent, respect_robots=False) as client:
postings = await GreenhouseAdapter().fetch({"token": "meridian"}, client)
assert postings[0].location_raw == "Austin, TX" # location is an object, not a stringSome tests exist to protect a rule rather than a feature. Do not delete or loosen them to get a change through:
| Test file | What it protects |
|---|---|
tests/test_filters_load.py |
The shipped filters.yml loads and uses no generator expressions. |
tests/test_docselect.py |
A hallucinated variant key is rejected, not substituted. |
tests/test_prompt_budgets.py |
Every rendered prompt fits its num_ctx with room for output. |
tests/test_packaging.py |
The PyInstaller spec, installer scripts and both workflows. |
tests/test_outbound_inventory.py |
Every web address in the shipped code is listed in docs/OUTBOUND-CALLS.md with its kind, and nothing listed is gone from the code. |
tests/test_static_cache.py |
No template links a static file without its build version, so each build's files can be cached for good. |
tests/test_about_sources.py |
Every registered source kind is in the catalog and docs/SOURCES.md, with an example config the Sources page accepts. |
If you change a prompt, regenerate the budget tables with uv run pytest -q -s -p no:cacheprovider tests/test_prompt_budgets.py -k table and update docs/PROMPT_BUDGETS.md.
- Use conventional-commit prefixes:
feat:,fix:,test:,chore:(CLAUDE.md). - Commit a coherent unit of work, with its tests. Do not push work in progress.
- Record any assumption you made in the pull request description, along with the alternative you rejected. The maintainer's private decision log is not in the repository, though code comments cite its IDs. Treat them as pointers to a private note, not as something to look up or copy into public text.
- If a check cannot pass in your environment (no GPU, no Ollama, no Edge), say exactly which command to run locally and mark the item
BLOCKEDin the description, noting that it requires a local run. Do not claim a gate passed that you could not run. - Windows-only behavior is the one thing only the Windows CI job can prove. Say so in the pull request.
- User-visible changes belong in
CHANGELOG.md, which has an[Unreleased]section at the top. Entries are plain and written for the person using the app: no pull request numbers, commit hashes, branch names or repository paths (docs/RELEASING.md). - Generated prose and UI copy use American English and no em dashes. UI colors come from the theme tokens in
kestrel/web/static/css/tokens.css(kestrel.cssis the legacy stylesheet thatbase.htmlloads first, and a converted page can replace it); do not hardcode a color (CLAUDE.md, "Output style").
GitHub Actions minutes are metered: Windows bills at 2x and macOS at 10x (CLAUDE.md, .github/workflows/ci.yml). The rule is that CI confirms; it does not discover.
- Finish the unit locally, run
scripts/check.py, then push once. Never push just to see what CI says. - A pull request runs Ubuntu and Windows. A push to
mainalso runs macOS. Pushes to other branches do not run CI on their own; the pull request does. - Changes that touch only
README.md,CLAUDE.md,AGENTS.mdordocs/images/**skip CI. The list is explicit on purpose, because LLM prompts are Markdown files underkestrel/llm/prompts/and tests readdocs/SOURCES.md.test_ci_skips_only_files_no_test_or_build_readsenforces this. - A new commit on the same ref cancels the CI run in progress (
concurrencyinci.yml). - Any warning in a CI or release log, such as a deprecated runtime, an annotation or a resource warning, becomes a failing local test in the same pull request, not a note for later.
- Action versions must be pinned to a major version that supports Node 24, and the tests check it (
tests/test_packaging.py). - For a packaging change, use the Release workflow's dry run with a single platform (
docs/RELEASING.md, "Dry run"). A full dry run builds all three installers.
CI itself runs uv sync --extra dev, uv run ruff check ., on Windows a compile of packaging/kestrel.iss against a stub program folder, and uv run pytest -q.
These come from CLAUDE.md. Breaking one makes the system harmful rather than merely imperfect. Where a rule has a clear home in the code, it is listed.
- Kestrel never acts on your behalf. It does not submit applications, send email or messages, click apply, or automate a social platform. It drafts and hands over. Your data reaches an online model only through an
external: truebackend, whichLLMClient.completerefuses unless you confirmed a Tier 3 preview or acknowledged Hosted mode (kestrel/llm/client.py). Every other thing Kestrel contacts is listed indocs/OUTBOUND-CALLS.md(Security and privacy model). - The model selects; it never invents. Every line in a PDF is the operator's own text from
doc_variant.text. The selection schema lists the real variant keys per slot, and a bad key is a validation failure that is flagged, never silently replaced (kestrel/llm/docselect.py,kestrel/docs/select.py,kestrel/docs/catalog.py). - Structured output or failure. Every model call is schema-validated, gets one repair attempt, and is then quarantined with the raw response. Never parse model output with a regular expression, and never let a parse failure crash a run (
kestrel/llm/guard.py). - Uncertainty escalates and never rejects. A low-confidence Tier 1 result becomes
keep, a quarantined Tier 1 item moves to Tier 2, and an ambiguous title passes Tier 0 (kestrel/pipeline/tier1.py,kestrel/pipeline/tier0.py). - Resumability is required. Every unit of work is a
taskrow, and killing the process at any moment must be safe. Do not keep important state only in memory (kestrel/queue/queue.py). - State sample sizes. A number from fewer than five observations is labeled insufficient, not shown as solid (
kestrel/intelligence/comp.py). - Public data only, politely. Check
robots.txtbefore reading any web page, send a descriptive User-Agent (SEC EDGAR requires one with a contact address), rate-limit every source, and never scrape behind a login (kestrel/ingest/http.py). Some calls skip therobots.txtcheck or Kestrel's own User-Agent by design, including JobSpy's requests to Indeed and Glassdoor, the public job-board APIs, the keyed APIs, SEC EDGAR and RSS feeds. They are listed in Security and privacy model. A request that skips either needs a reason in a code comment and a plain sentence indocs/OUTBOUND-CALLS.md. LinkedIn is not searched: a JobSpy source that names it is refused at config load (kestrel/ingest/adapters/jobspy.py).
Privacy rules that follow from these:
- No organization names in PDF metadata, headers or footers. Rendering leaves the header and footer empty and strips document metadata with
pypdf(kestrel/docs/render.py). - Confidential mode redacts the current employer from generated output and list views.
- No secrets in code, YAML, logs or committed files. API keys live in
.envin the data folder, and.gitignoreexcludes.envandprofile.yml. - All inference is local by default. Anything that could send data to a hosted model must say exactly what will be sent before the operator confirms.
From CLAUDE.md:
- Python 3.12, type hints everywhere, and
from __future__ import annotationsat the top of every module. - Async throughout ingestion, the model client and the web layer. JobSpy is synchronous, so it runs through
asyncio.to_thread()(kestrel/ingest/adapters/jobspy.py). Never put blockingrequestscalls on the event loop. - Catch specific exceptions. No bare
except:. A caught exception either recovers or is logged with context and re-raised. - Pydantic v2 at every boundary: config, model responses, API bodies.
- SQLAlchemy 2.0 style (
select(), notQuery) withaiosqlite. Alembic runs on a sync engine against the same file. Every connection sets WAL mode and a 5 second busy timeout (kestrel/db/engine.py). - Log with
structlog. Useprint()only for the CLI's own output. - Resolve every path through
kestrel/paths.pyand every packaged file throughimportlib.resources. The packaged app runs from a read-only directory, so never build a path from__file__. - Keep the worker, the scheduler and every database session on uvicorn's single event loop. A second loop produces cross-loop
aiosqliteerrors that look like corruption.
CLAUDE.md also lists platform traps that were verified against live services: context-window truncation on Ollama, how to turn thinking off per backend, the JSON Schema subset that constrained decoding accepts, simpleeval limits, PyInstaller one-folder builds, and the quirks of each ATS payload. Read that section before touching the model client, filters.yml, an adapter or packaging/.
Releases are one tag, and CI builds the three installers. The version lives in exactly one place, __version__ in kestrel/__init__.py. After bumping it, regenerate the Inno Setup include with uv run python packaging/gen_version_iss.py. Write the CHANGELOG.md section first and check it with uv run python scripts/changelog_section.py X.Y.Z. The full procedure, including signing and the website feed, is in docs/RELEASING.md.
Start here
Interfaces
Extending Kestrel
How it works
- Prompts and context budgets
- Document engine
- Learning loop internals
- Analytics internals
- Task queue and concurrency
- Database schema
Shipping and safety
- Packaging and releases
- Preflight and diagnostics
- Security and privacy model
- Outbound calls
- Benchmarking
Workarounds and Troubleshooting