Skip to content

#877 phase 2a: Jev org-kind suggestions (flag off), drainer, timer, health card - #902

Merged
gregoryfoster merged 13 commits into
mainfrom
feat/877-phase-2a-jev
Nov 27, 2026
Merged

gregoryfoster merged 13 commits into
mainfrom
feat/877-phase-2a-jev

Conversation

@gregoryfoster

@gregoryfoster gregoryfoster commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

#877 phase 2a: TypeSafe Jev suggests org kinds, with the flag off. Plan: docs/plans/2026-11-26-877-phase-2-jev-suggestions.md (approved 2026-11-26; revisions at its end). Design: docs/plans/2026-11-24-org-kind-suggestions-design.md. The gold set and its score are PR 2b; the flag stays off until that report is approved.

What ships

  • One question, shared (src/core/org_kind_question.py): the context, the org's state (display name, the registries that list it, up to 300 characters of active role titles; never a person's name), and the criteria (org_kinds.description, plus none). Production and the gold-set builder both use it, so the score measures what runs. One org per request, so it matches the harness exactly.
  • The Jev client (src/core/jev_client.py), modelled on the WSLCB tracker's: plain httpx. Retries 429/529; classes errors as transient or permanent; never logs or quotes the key. Tests run on httpx.MockTransport only.
  • The drain (classification.drain / reask): rules, then Jev for active orgs with no live answer from the pinned model, under an advisory lock. It writes suggestion and run rows only, never org_kind_id (the write sweep still holds). An answer from another model counts as a failure.
  • classification_runs: one row per drain that asked or failed. It feeds the health card.
  • In-process drainer (src/core/classification_drainer.py): started in the lifespan. Woken by wake() at every src/ org insert (swept), with a 5 s debounce, else every 15 min, at most 50 orgs. CLASSIFICATION_DRAINER=off leaves it out, and the test suite sets that.
  • CLI classify_suggestions.py --source all (with --limit and --reask-ids FILE), dry by default.
  • Daily timer power-map-classification. Its DB connect and Jev calls retry on the Timers: retry transient network failures, so a short outage doesn't cost a daily run #833 budget. Exit 3 (jev_failed) on a permanent failure, or after 48 h failing with no stored answer. The co-status monitor is requested in Dead-man monitor for power-map's org-kind classification timer (co-power-map-classification) status#144; the unit ships with an empty id, listed in PENDING_MONITORS.
  • Admin:
    • an AI-suggestions card on the dashboard;
    • on the Kind panel: the AI row and confidence, "accepted from AI · NN %", and Re-ask AI (one attempt, 20 s; disabled, with its reason, while the flag is off). Route count 417 → 418.
  • v0.83.0. The client diff is version-only.

Verified

  • pre-commit (the unit suite) on every commit;
  • the targeted integration modules, run alone: 415 passed;
  • a browser check on the dev server against the test DB, including one real Re-ask about a made-up org ("Legislature, 97 %"). axe is clean on the panel and the dashboard.

Deploy notes (operator)

  • Add TYPESAFE_API_KEY to /etc/power-map/.env, and leave JEV_SUGGESTIONS_ENABLED unset.
  • Install and enable the timer (docs/RUNBOOKS.md § Org-kind suggestions). Its first runs are rules-only.
  • Writes start without a command. After the restart, each API worker's drainer applies identifier rules every 15 minutes, even with the flag off (design D4). Phase 1 ran rules only by a supervised --execute. These are suggestion rows only, written on change; today's rules dry run plans 0.

TDD notes

  • The drainer loop, and the drain's permanent / last_answered_at additions, were written alongside their tests rather than after a red run. Their tests were written first and pass. Everything else went red first.
  • The runs table's DDL preceded its CHECK tests.

🤖 Generated with Claude Code

gregoryfoster and others added 13 commits November 26, 2026 21:21
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d the gold set

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… to match)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ion_runs

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tion timer

Jev errors say whether they are transient; the timer retries those on its #833
budget and alerts (exit 3, jev_failed) on a permanent failure or 48 h without
an answer. co-status monitor requested: CannObserv/status#144 (pending).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from provenance

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lan revisions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ules rows)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ting ok unrun

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant