Skip to content

Record Jev's profile suggestion in shadow mode (#39) - #45

Merged
datacas merged 1 commit into
mainfrom
issue-39-jev-shadow
Sep 23, 2026
Merged

datacas merged 1 commit into
mainfrom
issue-39-jev-shadow

Conversation

@datacas

@datacas datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner

Implements #39 (#39).

What changes in behaviour

  • New opt-in code_cycle.routing.jev block: mode: disabled|shadow (default disabled), model (only typesafe-ai/jev), timeout_seconds (default 3, at most 10). Unknown keys under code_cycle.routing and code_cycle.routing.jev are now refused before any stage runs.
  • In shadow, after an implement or resolve stage has been routed, dispatched and recorded, CycleRecorder asks Jev (POST https://www.jevai.org/api/v1/decisions, typed choice question) to pick cheap_coder or deep_coder. It records the answer on a separate shadow telemetry row. The adapter (scripts/jev_shadow.py) is an observer, not a ProfileSelector: nothing it returns reaches route(), target resolution, fallback or dispatch.
  • Payload: only allowlisted scalar fields from telemetry.PRE_ROUTING_SIGNALS (Añadir señales tipadas y estrictamente pre-routing a telemetry #35) plus the role. No prose, paths, diffs, repo/task/cycle ids, outcomes or secrets.
  • Key: read only from JEV_API_KEY at call time and placed only in the Authorization header. It is never stored in config, rows or logs.
  • Disabled / no key / failure: disabled builds no client and makes no request. A missing key records unavailable. Timeout, 429, 5xx, other HTTP errors and invalid responses each map to one closed jev_status category. No remote text is kept. The cycle's real decision is unchanged in every case.
  • Telemetry schema 4: shadow rows carry jev_rule_profile, jev_suggested_profile, jev_agreement, jev_confidence, jev_probability_<option>, jev_model_requested, jev_model_resolved/jev_model_resolution (resolved only when reported, and stored by name only when known), and jev_duration_ms. They are correlated by (cycle_id, stage_seq) with dispatch features and Registrar outcomes estructurados y correlacionables de cada ciclo #37 outcomes but never mixed with them. cycle_outcome() lists them under shadows, and first_pass_rate never reads a shadow row as the implementer. Probabilities outside [0, 1] are refused.
  • Standard library only. No new dependency.

Verification

  • python3 -m unittest discover -s tests: 580 tests, OK. This includes 27 new tests in tests/test_jev_shadow.py, covering config validation, the payload allowlist, key handling, response parsing and failure categories, disabled mode with no client or network, a disagreeing suggestion that leaves the dispatch identical, shadow rows free of signals and outcomes, and correlation.
  • python3 scripts/validate-package.py: VALID.

Residual risk

  • No call was made against the live Jev API. The response shape (data.answers.profile.{choice, confidence, probabilities}, optional data.model) comes from the public docs. If the real shape differs, every shadow records invalid_response and the cycle is unaffected.
  • The call is synchronous and is bounded per socket operation by timeout_seconds.

Closes #39

An opt-in observer, `code_cycle.routing.jev.mode: shadow` (default
`disabled`), asks Jev which of `cheap_coder` or `deep_coder` it would pick
for `implement` and `resolve` stages, and records the answer beside the
rules' choice. It is not a ProfileSelector: nothing it returns reaches
route(), target resolution, fallback or dispatch.

- The request carries only allowlisted scalar pre-routing signals from
  telemetry.PRE_ROUTING_SIGNALS plus the role, with a fixed choice
  question. No prose, paths, diffs, repo/task/cycle ids or outcomes.
- The key comes only from JEV_API_KEY at call time and goes only in the
  Authorization header. Disabled builds no client and makes no request;
  a missing key records `unavailable`.
- Failures are closed categories (unavailable, timeout, rate_limited,
  http_error, invalid_response); no remote text is kept, and none stops
  or changes the stage. The call is bounded by timeout_seconds (<= 10).
- Telemetry schema 4 adds `shadow` rows with the rules' profile, the
  suggestion, agreement, confidence, per-option probabilities and the
  requested/resolved Jev model, correlated by (cycle_id, stage_seq) and
  listed by cycle_outcome(). They hold no signals and no outcomes, and
  first_pass_rate never reads them as the implementer.
- code_cycle.routing and code_cycle.routing.jev refuse unknown keys; the
  mode, model and timeout are validated before any stage runs.

Standard library only; no new dependency.

Closes #39
@datacas

datacas commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

[CCR-20260923-001] · senior_reviewer · openai/gpt-6→? · ? · schema:1

Review summary

Reviewed the complete PR 45 diff from main to 2d9ddb017e9935bc4df9d8c4807af6b0a86b63e2, covering the Jev adapter, cycle integration, configuration validation, telemetry schema, documentation, and tests. No actionable findings.

Findings

None.

Security triage and audit

The deterministic security gate did not match any changed path, filename, or PR label. The reviewer-triggered security audit ran because this change sends pre-routing data and an environment credential to an external API. The audit covered the signal allowlist, request construction, JEV_API_KEY handling, response validation, failure handling, and telemetry persistence. No confirmed vulnerability was found.

A synthetic local 307 response was exercised against the transport: urllib returned the redirect response without issuing a follow-up request. The live Jev service was not called.

Validation and checks

  • git diff --check origin/main...HEAD — passed.
  • GitHub checks — all four completed successfully (two Bash installer checks and two PowerShell installer checks).
  • The PR description reports 580 Python unit tests passing; the suite was not rerun during this review.

Unverified items and residual risk

The live Jev API and the Python unit suite were not independently exercised. The PR description’s test result remains unverified here; the active GitHub checks cover package validation and installers.

Verdict

APPROVED — no open blocking findings; all reported GitHub checks passed.

@datacas
datacas merged commit 0ffcb0d into main Sep 23, 2026
4 checks passed
@datacas
datacas deleted the issue-39-jev-shadow branch September 24, 2026 09:21
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.

Añadir Jev opt-in como selector de perfiles en shadow mode

1 participant