Skip to content

Add optional Jev (TypeSafe System One) detector backend for complexity classification #22

Description

@preved911

Context

Raised in the chain-restructuring review (PR #17, "Think about jev usage for complicated commands detection"). Jev is a "System One" model: unstructured text in → typed structured decisions with calibrated probabilities out, ~70–500 ms, very cheap, schema outputs that cannot type-hallucinate.

Decision recorded in design.md: NOT in v1. The chain-restructuring change ships the deterministic AST-threshold detector only (per-line segment counts, nesting depth, inline-script statement counts). This issue tracks the follow-up.

Why a learned detector fits

The deterministic thresholds are brittle at the margins — "is this command too complex/unreadable to review?" is a fuzzy judgment. A structured-output classifier could:

  • score commands where hand-written thresholds disagree with intuition (long pipelines, deeply nested but benign substitutions)
  • drive smarter UX: reject only when complexity confidence is high; let borderline commands through to the normal human ask dialog

Proposed design

Optional, off-by-default detector backend in opencode-bash-guard.jsonc:

{
  "restructure": {
    "enabled": true,
    "detector": "jev"   // default "ast"
  }
}
  • "ast" (default): current deterministic path — remains the source of truth and the fallback whenever the classifier errors or times out
  • "jev": call the TypeSafe API with the command string, receive a structured decision ({ complex: boolean, confidence: number }-shaped schema), reject with the same actionable guidance when the decision is confidently "complex" and the chain resolves to ask

Constraints

  • Privacy: commands leave the machine → strictly opt-in, documented in README
  • Availability: on API failure/timeout → silent fallback to "ast" (never block, never throw)
  • Determinism of the steering guarantee must not depend on the service
  • Gated on Jev early-access availability and a stable API contract

Tasks

  • Config: parse + validate detector field (unknown values → warn + "ast")
  • Adapter: TypeSafe API client with timeout + typed response schema
  • Fallback path: jev error/timeout → ast decision, no behavior surprise
  • Tests with a mocked classifier (decide / pass / error / timeout)
  • README: privacy note + config example

/cc PR #17 discussion.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions