Metadata-Version: 2.4
Name: ninshubur
Version: 0.3.0
Summary: Policy-first intelligence crawler: trusted sources, declared extraction, timed suggestions.
License-Expression: AGPL-3.0-or-later
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx
Requires-Dist: pyyaml
Requires-Dist: tzdata; sys_platform == "win32"
Provides-Extra: api
Requires-Dist: fastapi; extra == "api"
Requires-Dist: uvicorn; extra == "api"
Provides-Extra: win
Requires-Dist: tzdata; extra == "win"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: anyio; extra == "dev"
Dynamic: license-file

<div align="center">

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="docs/img/banner-dark.svg">
  <img alt="Ninshubur: trusted sources in, declared fields out, timed suggestions" src="docs/img/banner-light.svg" width="720">
</picture>

**A general, policy-first crawler: allowlisted sources with trust tiers, declared fields only, raw pages never stored, and hostile input quarantined while the last good data keeps serving.**

What it finds becomes timed, costed suggestions you accept or dismiss. What counts as a good find is set by a profile you write: a job search is one profile, a client's list of target companies another. Nothing is ever executed automatically.

[![ci](https://github.com/alexb-joat/ninshubur/actions/workflows/ci.yml/badge.svg)](https://github.com/alexb-joat/ninshubur/actions/workflows/ci.yml)
[![codeql](https://github.com/alexb-joat/ninshubur/actions/workflows/codeql.yml/badge.svg)](https://github.com/alexb-joat/ninshubur/actions/workflows/codeql.yml)
![python](https://img.shields.io/badge/python-3.11%2B-3776AB)
![platforms](https://img.shields.io/badge/platform-linux%20%7C%20macOS%20%7C%20windows-555)
![dependencies](https://img.shields.io/badge/runtime%20dependencies-2-5fd6ae)
![network](https://img.shields.io/badge/fetches-admitted%20sources%20only-5fd6ae)
[![license](https://img.shields.io/badge/license-AGPL--3.0-blue)](LICENSE)

[Quick start](#quick-start) &nbsp;·&nbsp; [How a team uses it](#how-a-team-uses-it) &nbsp;·&nbsp; [Layout](#layout) &nbsp;·&nbsp; [What it will not do](#what-it-will-not-do) &nbsp;·&nbsp; [Operator guide](docs/USAGE.md) &nbsp;·&nbsp; [A live run, 27 Nov 2026](docs/live-run-2026-11-27.md)

<sub><i>Ninshubur (𒀭𒎏𒋚): the Sumerian messenger who carried word between realms and did exactly what was asked, nothing more.<br>Here it carries what reviewed sources say, and acts on nothing by itself.</i></sub>

</div>

<br>

**Measured: not yet as a filter.** Ninshubur's one model step (`ninshubur qualify`, run by hand) was checked against one person's labels. With the pre-registered prompt, the best Claude model (Opus 5.5) agreed with the labeller on 67 of 100 companies, against 68 for a rater that always says "no" (gap -1.0 points, 95% interval -11.0 to +9.0): not shown better. It found 7 of the 11 companies that person would say yes to, but also said yes to many they wouldn't, at $0.0075 per company assessed at list price. The method, a second sample and the limits are in [docs/case-study.md](docs/case-study.md).

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="docs/img/crawler-screen-dark.png">
  <img alt="The Crawler screen after a Look now at an invented job board. Left: the JSON the crawler received, with kept fields highlighted, undeclared keys struck through as never stored, and rows shaded where a prompt injection, a shell command, a hidden character and a missing or unsafe URL were caught, each with its reason. Right: the nine steps from robots.txt to done, with the taint step chosen." src="docs/img/crawler-screen-light.png" width="860">
</picture>

<sub>The Crawler screen (new in 0.3.0) after a Look now, from a demo data home with invented companies (`python scripts/demo_screen.py build DIR`), not from live data.</sub>

**Try it offline** from a clone, after `pip install -e .` (the [quick start](#quick-start) sets up a real installation):

```bash
export NINSHUBUR_HOME=$(mktemp -d) NINSHUBUR_CONFIG=config.example.yaml NINSHUBUR_PROFILES=profiles.example.yaml
ninshubur run --replay tests/samples   # the real pipeline on the shipped samples, no network
ninshubur suggest --top 3              # ranked suggestions with value, cost and evidence
```

## What it looks like

<!-- gen:readme-sample -->
```console
$ ninshubur status
sources: ok 5
  confs-2026           confs_tech   T1 rep 0.79 ok                   next 2026-11-26 14:06 review 2027-02-09
  event-sites          event_sites  T2 rep 0.53 ok                   next 2026-11-26 17:47 review 2027-01-12
  hn-freelancer        hn           T2 rep 0.52 ok                   next 2026-11-25 18:21 review 2027-01-10
  provider-docs-anthropic provider_docs T0 rep 0.90 ok                   next 2026-11-27 16:21 review 2027-01-12
  provider-docs-openai provider_docs T0 rep 0.90 ok                   next 2026-11-27 15:09 review 2027-01-12
items held 0, tainted 0; quarantine rows (7 d) 0; new candidates 9
suggestions: new 3

$ ninshubur suggest --top 1
#3 [conference_prospecting] Prospect Remote Growth Summit (Online, 2026-12-01): 7 paying companies, 11 speakers  (T2 unverified)
    value 75 USD  cost 23 USD  roi 2.3  confidence 0.50  profile agency-internal
    due 2026-11-26 (best: 2026-11-25 to 2026-11-25, Europe/Lisbon)  expires 2026-12-02
    - Remote Growth Summit starts 2026-12-01 in Online; 7 companies paid for presence, 11 speakers listed
    - profile match: 0 target companies, 1 speakers with target titles; geo/topic factor 0.50
```

<sub>Captured 2026-11-25 from the replay of `tests/samples` (`ninshubur run --replay tests/samples` in a temporary home), not from live data. Rebuild it with `python scripts/readme_sample.py --update`.</sub>
<!-- /gen -->

## Three rules

| Source trust policy | Declared extraction | Fail closed, degrade gracefully |
|---|---|---|
| A source is fetched only after a named reviewer admitted it through the H1–H8 checklist (`ninshubur sources test NAME`). Tiers 0–3 set starting reputation, review cadence and evidence weight. Links found in content become *candidates* for a human, never fetch targets. | Every adapter ships a schema; `project()` keeps only those fields, sanitises them and drops the rest. Raw bodies never touch disk. | Transport, structure and content detectors quarantine bad items (hashes only), downgrade the source (`suspect`, then `quarantined`), hold the affected suggestions and keep serving from the last known-good snapshot. |

These are tested invariants: over 1,700 tests, including a malicious-input corpus, run on Linux, macOS and Windows with Python 3.11, 3.13 and 3.14 (the explorer's tests run on Linux only). Two runtime dependencies (httpx, PyYAML; `tzdata` is added on Windows). A model is called only when you run `ninshubur qualify`.

## Status

This README describes the milestone Ninshubur is heading for. [docs/milestone.md](docs/milestone.md) lists where the code is still short of it.

Phase 1 (policy core, rules-only analysis): `confs_tech`, `greenhouse`, `ashby`, `lever`, `hn`, `statuspage`
adapters, plus `provider_docs` (LLM providers' model documentation, exported with `ninshubur export euboulia-facts` for the Euboulia extension); builders `cfp_submit`, `conference_prospecting`, `service_request_lead`,
`hiring_signal_outreach`, `tool_outage`; ICS calendar sink; Markdown/HTML/CSV exports; CLI. One LLM call, run by hand: `ninshubur qualify` asks a model the
profile's own question about each company and keeps only answers that cite evidence lines it was shown (local model by default; see docs/USAGE.md, 6c).

## Quick start

```bash
python -m venv .venv && . .venv/bin/activate
pip install -e .
mkdir -p ~/.ninshubur
cp config.example.yaml ~/.ninshubur/config.yaml
cp profiles.example.yaml ~/.ninshubur/profiles.yaml
ninshubur check                     # policy, config, schemas, review dates
ninshubur sources test confs-2026   # admission checklist H1-H8 against the live source
ninshubur run                       # fetch due sources, rebuild suggestions
ninshubur suggest --plan 45m        # best set for 45 minutes of human time
ninshubur show 3 && ninshubur accept 3
ninshubur status                    # health, held, quarantined, candidates
ninshubur serve                     # its own page at http://127.0.0.1:8790/ (this machine only)
```

## The page

New in 0.3.0. `ninshubur serve` opens Ninshubur's own web page on `127.0.0.1` (this machine only, port 8790): the crawler on or off, the two lines the data travels (admitted sources to suggestions, and the explorer's trial ladder with its breaker), every source with its health and why it is paused, the day's budgets, and the settings. It changes nothing until you press a button and confirm a preview: **Stop all fetching** (also `ninshubur stop "reason"` and `ninshubur resume`, a `STOP` file that every fetch checks), pause or resume a source, close the explorer's breaker, apply or undo a setting. The page opens the database read-only and uses only the standard library. How it is secured, the JSON it draws from (`ninshubur status --json`) and the contract for framing it inside another page are in docs/USAGE.md, section 8b.

Every step of a fetch can be watched live, page text included, and `ninshubur look SOURCE` fetches one source now to watch it, storing nothing; the page text exists only in memory and on an owner-only local socket, never on disk (docs/USAGE.md, section 8c).

The page has four tabs, Overview · Crawler · Prompts · Results, picked at the top or by the address (`#crawler`, `#prompts`, `#results`):

- **Crawler**: the page text as the crawler saw it beside the steps of the fetch, each step timed; Look now previews a look and starts it only when you confirm (pictured above).
- **Prompts**: edit a profile's qualify question with a live diff, try the edit on five companies you already decided with the local model before saving it (nothing is saved in the database), then apply it with a backup and undo.
- **Results**: every company once, with why it was suggested, its latest qualify answer and its evidence; accept or dismiss after a preview; and a 30-day scorecard for each source, every number with its count and window and every share with a 95% interval (docs/USAGE.md, section 8d).

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="docs/img/prompts-dark.png">
  <img alt="The Prompts tab: the demo profile's qualify question edited to add 'in Europe', a diff that shows only that line changed, and Try it on five companies already decided, each with the saved question's answer beside the edit's, the model's reason, tokens and time. One company's answer changed from no to unsure." src="docs/img/prompts-light.png" width="860">
</picture>

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="docs/img/results-dark.png">
  <img alt="The Results tab: five suggested companies with why each was suggested, confidence, value and cost, the qualify answer and accept and dismiss buttons, one row opened to its evidence; below, the 30-day scorecard of the four demo sources with fetch and parse success, taint, freshness, yield, agreement and corroboration, each with its count and interval." src="docs/img/results-light.png" width="860">
</picture>

<sub>Prompts and Results from the same demo data home; Try it was answered by a stand-in model in `scripts/demo_screen.py`, not a real one.</sub>

## How a team uses it

The full operator guide is [docs/USAGE.md](docs/USAGE.md). In short:

1. **One profile per client** in `~/.ninshubur/profiles.yaml` (start from `client-template` in
   `profiles.example.yaml`): cities and countries, titles, keywords and pains, target companies,
   providers in use, home base and home country. `ninshubur profiles check` says which suggestion
   kinds each profile can feed and what is missing.
2. **Admit the client's sources.** Target companies with a Greenhouse board:
   `ninshubur sources add acme-jobs --adapter greenhouse --param 'boards=[acme]' --tier 0 ...`
   runs the H1-H8 checklist and refuses anything that fails it. `sources candidates` lists hosts
   seen in content; they are never fetched until a human admits them (`--reject` clears noise).
3. **Run.** `ninshubur run` once, or `deploy/linux/install.sh` for the daemon. Each run fetches
   what is due, applies the policy, rebuilds suggestions and the calendar feed.
4. **Review.** `ninshubur suggest --profile <client>` ranks by return on human time;
   `suggest --held` shows what the policy is holding and why (tainted evidence, suspect source,
   needs corroboration). `show ID` prints steps, reasons with the full value/cost formula, and
   evidence with the exact extracted fields and fetch time. `accept`, `dismiss --reason`, `done
   --outcome` record the decision; accepted items land in `feeds/timings.ics`.
5. **Export for the weekly review.** `ninshubur export digest --profile <client> --format md`
   (or `html`, then Print to PDF in a browser; or `csv`) writes to `feeds/`. `export items --format csv`
   dumps everything gathered. The daemon writes one Markdown digest per profile each ISO week.
6. **Tune.** Costs and base values are in `config.yaml` (`costs`, `base_value_usd`); the formula
   in every suggestion shows which number to change. `ninshubur settings propose` shows what your
   recorded accept/dismiss/done decisions suggest for each of them, with the counts behind it; it
   writes nothing, and a number changes only when you apply it (`settings apply --yes` or the page).

Suggestion kinds today: `conference_prospecting` (the companies and speakers listed on an upcoming or recently held event's site; see docs/USAGE.md),
`cfp_submit` (call for papers closing in 3-90 days), `hiring_signal_outreach` (a target company or
a matching role is hiring: Greenhouse, Ashby and Lever boards and HN "Who is hiring?" posts), `service_request_lead`
(a public "seeking freelancer" style request matching the profile), `tool_outage` (a major incident
at a provider in `tools_in_use`). A crawl sends nothing but its page requests: no push, no telemetry.
A model is called only by `ninshubur qualify`, when you run it (a local model unless you name another).

Offline: `ninshubur run --replay tests/samples` runs the real pipeline on the shipped samples.
`python scripts/smoke.py` does that end to end in a temporary home; `pytest -q` runs the suite,
including the malicious-input corpus in `tests/test_malicious.py`.

## Known limits

What it does not do yet, each with the place that shows it (a test, a doc or a line of code):

- **The qualifier is not yet a filter.** With the prompt fixed in advance, no Claude model was shown to agree with one person's labels more often than a rater that always says "no". (docs/case-study.md:3)
- **One labeller, small samples.** The case study rests on one person's labels; nobody else labelled, so there is no human-to-human agreement to compare against. (docs/case-study.md:204)
- **The explorer runs on Linux only.** On macOS and Windows every `ninshubur explore` command refuses with the reason; the rest of Ninshubur runs as before. (tests/test_linux_only.py:1; ninshubur/explorer/__init__.py:19)
- **A host whose robots.txt answers 401 or 403 is off limits** until a person has read its terms and recorded that exact answer as `robots_reviewed_status` for the source, and only on the adapter's fixed hosts. (ninshubur/fetch.py:557; tests/test_fetch.py:215)
- **Only a source with an adapter can be read.** A source names one of the adapters in `ninshubur/adapters/`; a site none of them reads stays closed until someone writes one. (ninshubur/adapters/base.py:147)
- **Pages are read as the server sends them.** No browser or JavaScript engine is part of it (the runtime dependencies are httpx and PyYAML, and tzdata on Windows), so text a page builds in the browser is not seen. (pyproject.toml:12)
- **The content detectors match known patterns.** Hidden characters, prompt-injection phrasing, active HTML and key-like strings are flagged by pattern; a hostile page that uses none of them is not flagged. (ninshubur/detectors.py:86)
- **`forget` matches by name and leaves your own files as they are.** A namesake is forgotten and blocked too; exported files, config and profiles that mention the name are listed, and crawled text that mentions a person is counted, neither is rewritten; the retention sweep runs only while Ninshubur runs. (ninshubur/erase.py:8; ninshubur/schedule.py:379)

## Layout

```
ninshubur/policy.yaml   shipped floor; ~/.ninshubur/policy.yaml may tighten, never loosen
ninshubur/policy.py     allow_fetch, admission_check, allow_store, allow_llm
ninshubur/schemas.py    SCHEMAS registry + project()
ninshubur/detectors.py  transport / structure / content / behaviour detectors
ninshubur/fetch.py      the ONLY network gate (robots, pacing, caps, redirects, conditional GET)
ninshubur/ingest.py     quarantine, reputation, health, snapshots, items
ninshubur/schedule.py   due sources, run_source, growth/backoff
ninshubur/analyze/      relevance, timing, value, suggestion builders
ninshubur/sinks/        ics (the calendar feed)
ninshubur/erase.py      forget person|company, the forgotten list, the hourly retention sweep
```

Data lives in `~/.ninshubur` (`NINSHUBUR_HOME`): `ninshubur.db`, `logs/{fetch,policy}.jsonl`,
`feeds/timings.ics`. All files are 0600 on POSIX.

## What it will not do

No login, CAPTCHA or paywall bypass, no proxies or fingerprint evasion, no disguised User-Agent
(it always starts with `Ninshubur/`, so a site owner can block it in robots.txt by name), no LinkedIn / Facebook /
X / Reddit HTML, no person data outside the B2B professional whitelist, no cloud model for anything containing
person data. These are tested invariants, not configuration ([docs/guardrails.md](docs/guardrails.md) lists each
with its code and test).

The crawler doesn't fetch links it finds in a page, with one fenced exception: on an event site, up to 4
pages per page whose path names speakers, sponsors, exhibitors, partners, the lineup or the agenda, on the
same site only (G17). The explorer is the one part that
follows links. It fetches nothing until you run `ninshubur explore run`, `step` or `reach`, or install its hourly timer
with `deploy/linux/install-explorer.sh`, and it runs only on Linux. It asks `hn.algolia.com`, `api.github.com` and
`mastodon.social` about your profile topics and probes three job-board APIs, then follows links from what it
finds, at most 2 hops and 20 links per page. Its pages are parsed in a bubblewrap sandbox. Its requests go through the
same gate as the crawler's (robots.txt, the User-Agent, private addresses refused, STOP), under tighter limits
of its own: 5 seconds between requests to a host, at most 20 pages per site a day, 50 MB a day (G42).

## For site owners

If Ninshubur reaches your site, this is how to recognise it, block it and report it. The G numbers are rows in
[docs/guardrails.md](docs/guardrails.md), each with the code and the test behind it.

**Recognise it.** Every request's User-Agent starts with `Ninshubur/`. As shipped it reads
`Ninshubur/<version> (+https://github.com/alexb-joat/ninshubur; contact: https://github.com/alexb-joat/ninshubur/issues)`.
Whoever runs it may put their own contact after `Ninshubur/`, but can't remove that prefix (G1). Requests come
straight from that person's machine, never through a proxy (G26). It sends at most one request a second to your
host from each running copy, one at a time (G9).

**Block it.** Add this to your robots.txt:

```
User-agent: Ninshubur
Disallow: /
```

robots.txt is read for the token `Ninshubur`, whatever the rest of the User-Agent says, and the `*` group applies
when there is no `Ninshubur` group (G2, G3). A new rule takes effect the next time Ninshubur reads your robots.txt,
at most a day after its last read (G2). It honours `Crawl-delay` (G8). If your robots.txt can't be read (a server
error, a timeout, a redirect off your site), your whole host is off limits until it can be read, and Ninshubur asks
again after ten minutes (G4, G7).

**What it does with your answers.**
- robots.txt answering 401 or 403: your whole host is off limits. The one exception: the person running it has read
  your terms and recorded that exact answer for a source, and then only for the fixed hosts its adapter names (G5).
- A page answering 401, 403, 404 or 410: the source waits longer before each new try, and after five such answers in
  a row it stops until its operator clears it by hand (G43).
- 429 or 503: a `Retry-After` given in seconds is honoured for your host, up to one hour. A missing one, or one given
  as a date, counts as 60 seconds. Five server errors within ten minutes pause your host for an hour (G10).

**Report it.** Public reports: [GitHub issues](https://github.com/alexb-joat/ninshubur/issues). Anything sensitive:
[a private report](https://github.com/alexb-joat/ninshubur/security/advisories/new) ([SECURITY.md](SECURITY.md)).
Include the User-Agent, the time and your host. Ninshubur is open source, so a modified copy can change any of the
above, and this project can act only on its own code.

License: [GNU AGPL-3.0-or-later](LICENSE). Copyright (C) 2026 Alex Bubnov.

Ninshubur can run as a service, so the AGPL's network clause applies: a modified version offered to others over a network must ship its modified source under the same licence. The currently-public commits remain under their original MIT terms.

**Name:** "Ninshubur" is the project name, not part of the code licence. A fork must use a different name and must not imply endorsement by or affiliation with this project.
