Skip to content

feat(evolution): cached-digest provider pre-flight for cron stages, model-resolution fix (#486)#490

Merged
Lexus2016 merged 2 commits into
mainfrom
evolution/issue-486-cached-digest-preflight
Jun 24, 2026
Merged

feat(evolution): cached-digest provider pre-flight for cron stages, model-resolution fix (#486)#490
Lexus2016 merged 2 commits into
mainfrom
evolution/issue-486-cached-digest-preflight

Conversation

@Lexus2016

Copy link
Copy Markdown
Owner

What

Restores the evolution cached-digest provider pre-flight as a tracked, tested feature and fixes the root bug that made it fail on production with no model configured for pre-flight ping.

  • cron/evolution_preflight.py (new): a lightweight, non-streaming provider ping (max_tokens=1) plus a most-recent on-disk digest fallback for evolution pipeline cron stages (introspection / analysis / implementation / research / funnel / integration). Pre-flight is enabled by default and configurable via cron.preflight_enabled / cron.preflight_timeout_seconds.
  • cron/scheduler.py: integrates the pre-flight in _run_job_impl, between runtime resolution and AIAgent construction. On ping failure it returns the latest stale digest as a graceful-degradation success, or raises if no digest exists. Purely additive — the sync: merge upstream/main (286 commits) — 2026-06-23 #487 native model-resolution path (job.model > HERMES_MODEL > config.yaml model.default) is untouched, and non-evolution jobs (stage is None) skip the block entirely.
  • tests/cron/test_evolution_preflight.py (new): 27 tests covering stage detection, config, digest fallback, the ping per api_mode, and scheduler-level integration.

Why

When the configured provider is unreachable (e.g. Kimi timeout storms), evolution sessions burn retries/timeouts and deliver nothing. The pre-flight detects this quickly and falls back to the last good digest, so the pipeline keeps moving with stale-but-structured input instead of failing silently. This is graceful degradation, not a retry mechanism.

ROOT-FIX (this is why it failed on prod)

preflight_provider(runtime) reads runtime.get("model"), but resolve_runtime_provider() never populates a model key — the scheduler resolves the model into a separate local model variable and passes it to AIAgent(model=...) directly. On prod, runtime["model"] was therefore always empty, so the ping short-circuited with no model configured for pre-flight ping and the cached-digest fallback could never trigger.

Fix: before the ping, hand preflight_provider a runtime that carries the already-resolved model:

preflight_runtime = runtime if runtime.get("model") else {**runtime, "model": model}
err = evolution_preflight.preflight_provider(preflight_runtime, cfg=_cfg)

A shallow copy (not in-place mutation) keeps the ping side-effect-free, and the guard never clobbers a model the runtime may already carry (e.g. ACP-resolved). The local model is guaranteed non-empty at this point — _run_job_impl raises earlier if no model resolves.

Provenance

This feature previously existed only as untracked local code on the prod host; a git stash -u during a deploy hid it, and upstream-merge #487 overwrote scheduler.py with the native version without it. This PR restores it into git from that stash, with the root bug fixed.

Tested

  • tests/cron/test_evolution_preflight.py27 passed. Includes a new unit test (test_resolved_model_does_not_bail_no_model) and a scheduler-level test (test_root_fix_runtime_model_synced_from_config_default) that reproduces the exact prod condition: resolve_runtime_provider() returns a runtime with no model, the job pins no model, and config.yaml supplies model.default. It asserts the runtime handed to the ping carries the resolved default.
  • Negative control verified: that root-fix test fails without the fix (captured['model'] == None) and passes with it — so it genuinely exercises the bug.
  • Adjacent suites green: test_scheduler_provider.py (29), test_scheduler.py model/runtime/run_job slice (77), test_run_one_job.py + test_codex_execution_paths.py (8).
  • Syntax: ast.parse clean on all three files.

Closes #486.

…odel-resolution fix (#486)

Restore the evolution cached-digest pre-flight as a tracked feature and fix
the root bug that made it fail on prod with 'no model configured for
pre-flight ping'.

What:
- cron/evolution_preflight.py: lightweight non-streaming provider ping plus
  most-recent on-disk digest fallback for evolution pipeline cron stages
  (introspection/analysis/implementation/research/funnel/integration).
- cron/scheduler.py: integrate the pre-flight between runtime resolution and
  AIAgent construction. On ping failure, return the latest stale digest
  (graceful degradation) or raise if none exists. Purely additive — the
  #487 native model-resolution path is unchanged.

Why:
- When the configured provider is unreachable (e.g. Kimi timeout storms),
  evolution sessions burn retries/timeouts and deliver nothing. The pre-flight
  detects this fast and falls back to the last good digest so the pipeline
  keeps moving with stale-but-structured input instead of failing silently.

ROOT-FIX:
- preflight_provider() reads runtime['model'], but resolve_runtime_provider()
  never populates it — the scheduler resolves the model into a separate local
  'model' variable (job.model > HERMES_MODEL > config.yaml model.default) and
  passes it to AIAgent(model=...) directly. On prod runtime['model'] was empty
  so the ping always returned 'no model configured' and the cached-digest
  fallback could never trigger. Fixed by syncing runtime['model'] = model
  (the already-resolved local) before the ping, without clobbering an
  ACP-resolved model.

Provenance:
- This feature previously existed only as untracked local code on the prod
  host; git stash -u hid it and upstream-merge #487 overwrote scheduler.py
  with the native version. Now restored into git from that stash, with the
  root bug fixed.

Tested:
- tests/cron/test_evolution_preflight.py (27 tests) pass, including a new
  unit test and a scheduler-level test that reproduces the prod failure
  (runtime returned with NO model + empty job.model + config.yaml
  model.default) and asserts runtime['model'] is synced to the resolved
  default. Verified the new test FAILS without the root-fix (captured
  model == None) and PASSES with it.
- Adjacent suites green: test_scheduler_provider.py (29), scheduler
  model/runtime/run_job slice (77), test_run_one_job.py + codex paths (8).
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: evolution/issue-486-cached-digest-preflight vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 11397 on HEAD, 11396 on base (🆕 +1)

🆕 New issues (4):

Rule Count
unresolved-import 3
invalid-assignment 1
First entries
cron/evolution_preflight.py:231: [unresolved-import] unresolved-import: Cannot resolve imported module `anthropic`
tests/cron/test_evolution_preflight.py:7: [unresolved-import] unresolved-import: Cannot resolve imported module `pytest`
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
cron/evolution_preflight.py:204: [unresolved-import] unresolved-import: Cannot resolve imported module `openai`

✅ Fixed issues (2):

Rule Count
unresolved-attribute 2
First entries
run_agent.py:3221: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`

Unchanged: 6028 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

…486)

CI test shard 5 lacks the optional 'anthropic' package, so
test_anthropic_success / test_anthropic_failure failed with
ModuleNotFoundError instead of being skipped. Add a per-test
pytest.importorskip('anthropic') guard so they SKIP when the
optional dependency is missing. Applied per-test (not class-level)
because the other TestPreflightProvider cases (openai, missing_api_key,
missing_model, acp, root-fix unit) do not touch anthropic and must
keep running.
@Lexus2016 Lexus2016 merged commit 93293ac into main Jun 24, 2026
51 of 53 checks passed
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.

[FIX] Evolution pipeline produces zero deliverables — 100% cron failure rate; add pre-flight provider check + cached digest fallback

1 participant