Skip to content

About

A local overnight agent: DataContractGate checks last night's data drops, local Gemma writes a two-line morning summary, AISchemaGate checks Gemma.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

MorningDrop 🦥

Your data drops get checked overnight. You get two lines in the morning.

MorningDrop is a small local agent for anyone who wakes up to a folder of nightly exports: vendor CSVs, storefront dumps, CRM extracts. While you sleep it

  1. finds the files that are new since last night,
  2. checks every row against a DataContractGate contract, fully offline,
  3. asks a local Gemma model (via Ollama) for a two-line summary and suggested fixes,
  4. checks Gemma's answer with AISchemaGate before it reaches you, and
  5. writes reports/YYYY-MM-DD.md, .json and a two-line latest.txt.

No rows leave your machine. No API keys. No per-call bill.

MorningDrop demo: a messy night checked by local gemma3:4b, then a clean night

Recorded on a CPU-only box with asciinema + agg; the ~15–30 s Gemma wait is trimmed. Raw cast: docs/demo.cast.

$ morningdrop run
The orders_2026-10-24.csv file failed for 63 rows due to currency and quantity issues.
Prioritize fixing the currency and quantity validation rules in the orders contract.
report: reports/2026-10-25.md  (21.7s, summary by model)

Full sample: samples/expected-report.md (a real gemma3:4b run on a CPU-only box).

Why the model's output gets a contract too

A small local model is great at turning 60 × enum_violation on currency into a sentence a tired human can act on. It is also happy to invent a file called payments.csv, say a red night is green, or repeat your prompt back. So MorningDrop treats Gemma the way it treats a vendor: its output has a contract.

Check Library What it catches
Shape: status enum, line1/line2 length, every fix has file, field, kind, suggestion AISchemaGate (summary_contract.yaml) prose instead of JSON, missing keys, a 400-character "line"
Status equals the worst file's status MorningDrop grounding "all green!" on a red night
line1/line2 name the worst file MorningDrop grounding leading with the wrong problem
Every number in the text already appears in the facts MorningDrop grounding "41 of 300 rows failed" when nothing like that happened
Fixes point at real files and real failing fields MorningDrop grounding invented files and columns

When a check fails, the violations go back to Gemma as a repair prompt (up to max_retries). If only some fixes are bad, those fixes are quarantined and the rest are kept, the same way DataContractGate quarantines bad rows. If the model never gets it right, or Ollama isn't running, a plain template writes the report from the same facts. You always get a correct morning report. And on a quiet night where everything passed, the model isn't called at all.

What we saw while building it (sample drops, CPU only):

Model Result
gemma3:4b Accepted on the first attempt, about 20–35 s
gemma3:1b Valid JSON, but led with the wrong file on all 3 attempts (earlier prompt versions: invented "12 of 80 rows failed" in a file with no contract). Fallback report
gemma3:270m Echoed the instructions back as its summary and suggested fixing data in a file with no failures. Fallback report

Quick start

git clone https://github.com/nightmoose/morningdrop && cd morningdrop
python -m venv .venv && . .venv/bin/activate
pip install -e .
ollama pull gemma3:4b         # or gemma3:1b on a small laptop
morningdrop run               # uses morningdrop.yaml -> samples/drops
cat reports/latest.txt

No Ollama yet? MORNINGDROP_LLM_BACKEND=mock morningdrop run runs the whole pipeline with a deterministic stand-in model.

Point it at your own folder by editing morningdrop.yaml:

watch: /data/nightly          # where the exports land
contracts: contracts          # one DataContractGate YAML per dataset
llm:
  backend: ollama             # ollama | openai | mock
  base_url: http://localhost:11434
  model: gemma3:4b

Any OpenAI-compatible local server works too (llama.cpp llama-server, vLLM, LM Studio): set backend: openai and base_url. Environment overrides: MORNINGDROP_LLM_BACKEND, MORNINGDROP_LLM_URL, MORNINGDROP_LLM_MODEL.

Then schedule it: examples/crontab.txt, macOS launchd, or a systemd watch service.

How files map to contracts

orders_2026-10-24.csv → dataset orders → contracts/orders.yaml. The date suffix is stripped. CSV, JSON (array or {"records": [...]}) and JSONL are supported. CSV cells are coerced to the contract's declared types; a value that won't coerce stays a string, so DataContractGate reports an honest type_mismatch.

New dataset, no contract yet? MorningDrop drafts one from the file (types, required fields, ranges, small enums, date patterns), compiles it with DataContractGate to prove it's valid, and saves it to contracts/_proposed/. It is never enforced until you move it into contracts/. You can also run morningdrop infer path/to/file.csv.

Re-sent files are recognized by content hash, so the same file twice doesn't produce a second report.

What the model sees

Only counts, field names, violation messages and the contract rule that was broken, never whole rows. Passing rows are not sent to the model at all. Violation messages can quote a bad value (value "usa" does not match), which is the point, and it all stays on your machine anyway.

Optional: tracing hook

If SENTRY_DSN is set and sentry-sdk is installed (pip install -e '.[sentry]'), each run emits spans for the DataContractGate checks, Gemma calls and AISchemaGate checks. Without it, this does nothing and nothing is sent anywhere.

Development

pip install -e '.[dev]'
pytest -q                                                    # offline, uses scripted fake models
MORNINGDROP_LIVE=1 MORNINGDROP_LLM_MODEL=gemma3:4b pytest -s tests/test_live_gemma.py   # real Gemma

CI runs the offline suite on Python 3.9 and 3.12, plus a best-effort job that installs Ollama and runs gemma3:1b end to end on a CPU runner.

Built on

  • Gemma open-weight models, served by Ollama
  • DataContractGate (MIT): the contractgate Python package's offline validator
  • AISchemaGate (MIT): the aischemagate package, same engine, pointed at LLM output

License

MIT

About

A local overnight agent: DataContractGate checks last night's data drops, local Gemma writes a two-line morning summary, AISchemaGate checks Gemma.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages