Repository navigation
feat(bin): add a local Rizzo Flow backend to the Jev shadow wake classifier - #45
Merged
Merged
Conversation
added 5 commits
September 26, 2026 23:57
…ifier config/jev-endpoint selects a loopback Jev-compatible server (e.g. Rizzo Flow's `rizzo serve`) over the existing OpenRouter path: no API key, no spend cap, a 1-minute load-average ceiling pause instead (config/jev-max-load), and non-loopback URLs refused outright. The OpenRouter path stays byte-identical when config/jev-endpoint is absent.
…ank-file handling
Guards the rebase onto #44's configurable timeout: both backends now share one JEV_TIMEOUT read once per drain, so the override must apply identically whichever backend is selected.
alandomio
force-pushed
the
fm/jev-local-rizzo
branch
from
September 26, 2026 22:01
c555547 to
91c1a5e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
The developer wanted bin/fm-jev.sh to classify supervision wakes through a local Rizzo Flow server, meaning a Jev-compatible /v1/systemone endpoint on 127.0.0.1. Each home should be able to choose it, and it must need no API key. Instead of a spend cap it should pause when the load average is too high, it should refuse non-loopback endpoints, and a missing usage cost should count as normal. The OpenRouter path had to stay unchanged for homes that use it. After relaunch, the concrete goal was to rebase the existing branch, PR #45, onto origin/main. That meant resolving conflicts with #44's configurable Jev request timeout (default 5 seconds), keeping that timeout, and making config/jev-timeout also apply to the local backend. The developer also required updated docs, the AGENTS.md config line and tests, including one proving the timeout applies to the local backend. The work had to be proven with a live run against the permanent local rizzo serve on 127.0.0.1:8017 and then re-validated through the no-mistakes gate toward a green PR on github.com/alandomio/firstmate.
What Changed
bin/fm-jev.shandbin/fm-jev-lib.shadd a second, keyless Jev backend. A home selects it with a non-emptyconfig/jev-endpoint, which wins overOPENROUTER_API_KEYwhen both are set. Requests go to<base>/v1/systemone(for example, Rizzo Flow'srizzo serveon127.0.0.1:8017) through curl with the proxy bypassed. Only a bare loopback origin (127.0.0.1,localhostor[::1], no path) is accepted. Any other URL is never dialed: the row is logged as skipped withinvalid-endpointand classification pauses for the day. The OpenRouter path works as before.usage.costis not an error there. Instead, each request first checks the 1-minute load average againstconfig/jev-max-load(default 8). If the load is at or above that ceiling, the row is skipped withwhy=loadand the next reading below it classifies again.config/jev-timeout(default 5s) now applies to both backends, andstatusreports the active backend along with either its spend/cap or its endpoint and load ceiling.AGENTS.mdlistsconfig/jev-endpointandconfig/jev-max-loadand updates the timeout and cap lines, anddocs/configuration.mdanddocs/scripts.mddescribe both backends plus the test-onlyFM_JEV_LOAD_OVERRIDE.tests/fm-jev.test.shgains tests for the local backend, and a newtests/fm-jev-local-rizzo-live.test.shruns a live check against a local Rizzo server.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The latest fix round does exactly what was prescribed. A load reading at or above the ceiling now only logs that row as skipped (why=load), with no day-long pause, and the next reading below the ceiling classifies again. The backend gate checks the file with the builtin -s test before it runs grep, so a home without config/jev-endpoint starts no process. The OpenRouter path, the loopback check, the timeout handling and the report logic still behave as before, and the updated tests assert the right outcomes.
Testing
I ran the targeted Jev suite (all 22 cases pass) and the opt-in live test against the permanent rizzo serve on 127.0.0.1:8017 (classified in 296ms, cost=null). I also did a manual live drain: a load spike above the ceiling skipped only that wake with no day pause, and a later drain below the ceiling classified the next wake on the same day. A logging fake grep confirmed the backend gate starts no process for a home without config/jev-endpoint and still rejects a whitespace-only file. Everything passed, and the worktree was left clean. There is no UI surface; the evidence is CLI and log transcripts.
Evidence: Live load-spike skip, same-day resume, status, and gate process cost transcript
Source: Live load-spike skip, same-day resume, status, and gate process cost transcript
== drain 1: 1-minute load 9.5 >= ceiling 4 == {"id":"1790000000:1","outcome":"skipped","why":"load"} state/jev/disabled: absent (no day pause) == drain 2: load back to 0.5, same day == {"id":"1790000000:2","outcome":"classified","model":"rizzo-flow-1.7b-q8_0","choice":"firstmate","cost":null,"ms":270} state/jev/disabled: absent Jev shadow triage: on, local backend (config/jev-endpoint = http://127.0.0.1:8017) load ceiling: 4 (1-minute average) request timeout: 5s none endpoint file -> backend=disabled, grep execs=0 blank endpoint file -> backend=disabled, grep execs=1 local endpoint file -> backend=local, grep execs=1Evidence: Script that produced the live transcript
Source: Script that produced the live transcript
Evidence: Opt-in live Rizzo test output
Source: Opt-in live Rizzo test output
ok - classified live against http://127.0.0.1:8017 in 296ms: model=rizzo-flow-1.7b-q8_0 choice=firstmate cost=nullEvidence: Targeted Jev suite output
Source: Targeted Jev suite output
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 3 issues found → auto-fixed ✅
bin/fm-jev-lib.sh:36- fm_jev_backend now starts agrepprocess on every hook call once the-efstate check passes, even when config/jev-endpoint doesn't exist. This happens on every fm-send, fm-control, captain hold, drain, and turn end. Before this change, a home that hadn't opted in returned after a single[ -f "$home/.env" ]builtin test, with no process started. The lib header still says the function 'costs one file test when the home has not opted in', and docs/configuration.md says 'one cheap file check'. Every home using the OpenRouter backend, or no backend, now pays an extra fork+exec on those hot paths. Fix: guard the grep with a builtin test first, e.g.if [ -s "$home/config/jev-endpoint" ] && grep -q '[^[:space:]]' "$home/config/jev-endpoint" 2>/dev/null; then. That keeps the whitespace-only handling and the cost stays one stat when the file is absent.bin/fm-jev.sh:438- One reading of the 1-minute load average at or above the ceiling (default 8) writes state/jev/disabled for the whole local day, the same as the spend cap. A spend cap only goes up during a day. Load average is momentary: a single build or a burst of fleet agents on the same machine stops local shadow classification until midnight, even if load drops a minute later. This machine runs many agents, so the default could pause the local backend on most days and starve the one-week shadow measurement. The alternative is to skip only the affected rows while load is high (log them as skipped with why=load) and not write the day-long pause. This matches the stated intent ('pause when the load average is too high') and the docs, so whether a whole-day pause is the right granularity is the author's call.bin/fm-jev.sh:159- Round 2 moved config/jev-endpoint and config/jev-max-load to$FM_HOME/config, so the local backend's settings are read from the same place that selected it. config/jev-timeout, which this change now also applies to the local backend, is still read from$CONFIG, and that honours FM_CONFIG_OVERRIDE. Take a detached drain that inherits FM_CONFIG_OVERRIDE (exported by fm-remote-secondmate-control.sh or fm-stow-cascade.sh). It dials the home's local endpoint under the home's load ceiling, but uses the override directory's timeout, or the 5 s default, instead of the home's config/jev-timeout. This read predates the change (feat(bin): make the Jev request timeout configurable, default 5 seconds #44) and is shared with the OpenRouter backend. Moving it would change OpenRouter behaviour, which the intent says must stay unchanged, so this needs the author's decision.🔧 Fix: Skip rows on Jev load spikes; cheap backend gate
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-jev.test.sh: full targeted Jev suite, 22 cases, all ok, includingtest_local_backend_load_ceiling_skips_without_a_day_pause, the timeout-applies-to-local case, loopback refusal, whitespace-only endpoint, and the FM_CONFIG_OVERRIDE home-config caseFM_JEV_RIZZO_LIVE=1 bash tests/fm-jev-local-rizzo-live.test.shagainst the live rizzo serve on 127.0.0.1:8017curl -sS http://127.0.0.1:8017/v1/models: confirmed the live server answers and has the jev-latest aliasManual live drain transcript (live-load-skip-and-gate.sh): drain at load 9.5 with ceiling 4 gives skipped/why=load and no state/jev/disabled; a same-day drain at load 0.5 is classified by rizzo-flow-1.7b-q8_0 in 270ms with cost=null;fm-jev.sh statusshows the local backend, load ceiling 4 and timeout 5sManual gate-cost check: put a logging fakegrepfirst on PATH and calledfm_jev_backend: no endpoint file gives 0 grep execs (disabled); a whitespace-only file gives 1 exec (still disabled); a real endpoint gives 1 exec (local)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.