Skip to content

feat(protocol)!: add the per-session Jev mode switcher (ADR-0042) - #166

Closed
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1790291940-jev-mode-kernel
Closed

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1790291940-jev-mode-kernel

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

What changes for users

Every session gains a second switcher beside the model/effort one: a Jev mode with five rungs low | medium | high | max | ultrajev (or none, to clear).

  • On the wire: set_jev_mode { session_id, mode? } on POST /v1/sessions/jev-mode, outcome jev_mode_set, and the optional SessionSummary.jev_mode on every session_updated / snapshot, so web, desktop, mobile, and the TUI all read the same state from the qq-client reducer (SessionClient::set_jev_mode).
  • The mode is applied at the next run claim; an active run keeps the plan it compiled. Spawned children inherit the parent's pin.
  • The regular model switcher is unchanged: set_session_model / set_session_effort, TUI /models / /effort, and the existing HTTP routes already are the provider-neutral model and reasoning-effort controls, so no duplicate SetModel was added.
  • approval_delegate (config / QQ_APPROVAL_DELEGATE) now also accepts by_mode, naming the default explicitly.

The TUI /jev picker lands in the stacked follow-up PR.

Why / design

ADR-0042 (docs/adr/0042-session-model-and-jev-mode-switchers.md). Key decisions:

  • TypeSafe's public Jev API exposes no effort/mode request parameter (one versioned model, typed decisions). Rather than invent one, JevMode is a QQ-local ladder over the three existing Jev roles already composed at the root: task routing, checkpoint review (off | final | enforce), and approval delegate (off | by_mode | on). The protocol value is opaque; only src/runtime.rs knows the table:

    mode routing review approval delegate
    low on off off
    medium on final off
    high on enforce off
    max on enforce by_mode
    ultrajev on enforce on

    This exact table is a founder decision flagged in the ADR; changing it touches only jev_mode_rung.

  • Precedence: configured/profile < session jev_mode < explicit inherited routing/checkpoint selections (a child's resolved policy still wins). A rung never widens Jev consent or the approval mode's ceiling, and fails closed (RuntimeLoadError::Configuration) when no typesafe-jev credential is stored — exactly like jev_routing: true.

  • Persistence follows the existing approval_delegate pattern: UPDATE sessions … ; load summary; append session_updated in one transaction, publish after commit. ClaimedRun.jev_mode → RuntimeLoadRequest.jev_mode → loader overrides.

  • No new qq-provider Jev adapter: the existing TypeSafeTaskRouter / TypeSafeCheckpointReviewer / JevApprovalReviewer already implement the roles through core traits (qq feat(runtime): enforce JEV checkpoints and add effort transport #72/feat(runtime): make Jev review opt-in and account for bounded assessments #74). The Anthropic-efforts PRs (feat(provider)!: add model-specific efforts and Anthropic discovery #154–feat(provider)!: preserve Anthropic thinking for Opus 5.5 #157) are orthogonal and untouched.

Linear: ENG-
Slice: docs/adr/0042-session-model-and-jev-mode-switchers.md

How verified

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace (qq-core 723 passed, qq bin 228, qq-tui 323, qq-client 23, qq-server 27, qq-protocol 48 + fixtures)
  • cargo test -p qq-provider --no-default-features --features test-support (171 + 17 passed)
  • Manual check: not run against a live TypeSafe key (deterministic tests use a stored fixture credential).

New tests:

  • qq-protocol: jev_mode_spellings_are_stable_and_ordered, set_jev_mode_is_a_work_command_on_its_own_route, wire/headless goldens v29.
  • qq-core: set_jev_mode_persists_publishes_and_is_inherited_by_children, jev_mode_reaches_the_loader_at_the_next_claim_not_the_active_run, version_thirty_six_gains_the_jev_mode_and_rejects_a_bad_shape.
  • qq (runtime): jev_mode_rungs_map_onto_the_jev_roles_at_load (all five rungs, fail-closed without a credential, inherited selections win), jev_mode_rungs_are_monotone.
  • qq-client: session_updated_carries_the_jev_mode_to_every_surface; session_management_commands_reach_their_routes_and_only_theirs now covers /v1/sessions/jev-mode end to end.

Impact

  • Performance: none on the streaming path. One extra nullable column read at claim; the loader override is a const fn table lookup at plan compile.
  • Compatibility: PROTOCOL 28→29 (additive fields, new command/outcome tags; v23–v28 goldens retained decode-only). Store schema 36→37 (ALTER TABLE sessions ADD COLUMN jev_mode TEXT, migration + shape test). Descriptor unchanged. Harbor trace fixture headers bumped to 29.
  • Docs: docs/design/protocol.md (version 29, route, endpoint), docs/runbooks/jev.md (ladder section), docs/guide/configuration.md (by_mode), docs/adr/README.md, docs/plans/progress/root.md.

Link to Devin session: https://app.devin.ai/sessions/5288c73e9e644e0dad0a0c23700b9b46
Open in Devin Desktop: https://app.devin.ai/desktop/session/5288c73e9e644e0dad0a0c23700b9b46?variant=devin
Requested by: @integrate-your-mind

Protocol 29 adds set_jev_mode / jev_mode_set on /v1/sessions/jev-mode and
the optional SessionSummary.jev_mode (low | medium | high | max | ultrajev,
absent to clear). The value is opaque on the wire; the composition root maps
each rung onto jev_routing / jev_review / approval_delegate when the next
run is claimed, so an active run keeps its compiled plan. The regular model
switcher (set_session_model / set_session_effort) is unchanged and remains
the provider-neutral model and reasoning-effort control.

Store schema 37 adds the nullable sessions.jev_mode column; the command
writes it and appends session_updated in one transaction before publishing.
Children inherit the parent's pin; a child's resolved routing/checkpoint
selection still wins over it. A rung never widens Jev consent or the
approval ceiling and fails closed without a Jev credential.

ApprovalDelegateSetting gains by_mode so the ladder can name the default
explicitly.

Verification: cargo test --workspace, fmt --check, clippy -D warnings,
cargo test -p qq-provider --no-default-features --features test-support.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@lg2m

lg2m commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

this is good, i want to keep it open until we do more thorough testing with jev and got the implementation in a place where jev is actually able to provide value. currently jev is failing almost 70% of the approval delegations and routes. i will take a look and add another PR addressing.

@lg2m
lg2m self-requested a review September 25, 2026 14:57
@lg2m
lg2m marked this pull request as draft September 25, 2026 14:57
@integrate-your-mind

Copy link
Copy Markdown
Collaborator

Incorporated by replacement in merged #181, main 2103aa5. Independent exact-source review accounted for the full #166/#170 stack (107 paths), including versioned wire-fixture moves, ADR numbering, session persistence and TUI behavior. Retained integration c5a5836 includes exact #170 as its second parent and this head beneath it; the reviewed replacement tree is now main. This PR itself is closed, not described as merged. Original head 83455ec and branch are retained. Review report SHA256 c84c39eb2f75aa066e68517f83dee144fb565989b20b2142702ebe6d947cd0dd. No unique output was discarded; live runtime/release qualification remains separate.

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.

2 participants