Skip to content

refactor(llc): config consolidation + LLCRunStatus.is_terminal() + middleware dedup + fix broken test (#9776, #9777, #9763) - #9829

Merged
mrveiss merged 1 commit into
Dev_new_guifrom
issue-9776
Jun 9, 2026
Merged

mrveiss merged 1 commit into
Dev_new_guifrom
issue-9776

Conversation

@mrveiss

@mrveiss mrveiss commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Thinking Path

Three related LLC-hygiene gaps surfaced while auditing the heartbeat/adapter work: a shadowed dead config module (#9776), duplicated terminal-status + key-validation logic (#9777), and a structurally-broken test (#9763). Grouped here as one focused hygiene PR.

What Changed

#9776 — config consolidation
llc/config.py (flat) was shadowed by the llc/config/ package, so it was dead and its DEFAULT_STREAMING_WATCHDOG_TIMEOUT was unreachable (ImportError). Folded the constant into config/__init__.py and deleted the flat module. All three constants now import.

#9777 — consolidation

  • LLCRunStatus.is_terminal() is now the single source of truth for the terminal/non-terminal split — replaces the scheduler's _NONTERMINAL_STATUSES frozenset and the two subscription adapters' in (COMPLETED, FAILED) checks.
  • agent_auth middleware now calls ApiKeyService.validate_key (hash + revoked + expiry) instead of re-implementing the query + _hash_key — the very duplication that forced the two-place expires_at edit in feat(llc/scheduler): route claude_code heartbeats through adapter registry + run-scoped key (#9622, #9623) #9772. They can no longer drift.

#9763 — broken test
test_invoke_writes_state_file patched builtins.open then asserted the state file exists on disk (impossible). Dropped the patch so the file is written for real to the temp dir.

Verification

$ python3 -m pytest llc/adapters/tests/ llc/tests/test_heartbeat_scheduler.py llc/tests/test_api_keys.py \
    llc/tests/test_run_status_terminal.py llc/tests/test_agent_auth_middleware.py llc/tests/test_heartbeat_context.py -q
163 passed

Zero failures — the previously-perennial test_invoke_writes_state_file (#9763) now passes. New tests: test_run_status_terminal.py (terminal/non-terminal partition is total) and test_agent_auth_middleware.py (passthrough / missing-bearer 401 / invalid-key 401 via validate_key / valid-key sets request.state) — the middleware had no tests before.

Closes #9776. Closes #9777. Closes #9763.

Model Used

claude-opus-4-8 (1M context)

…tion + fix broken test (#9776, #9777, #9763)

#9776 — llc/config.py was shadowed by the llc/config/ package (dead module;
DEFAULT_STREAMING_WATCHDOG_TIMEOUT unreachable, AGENT_API_BASE_URL duplicated).
Folded the unique constant into config/__init__.py and deleted the flat module;
all three constants now import cleanly.

#9777 — added LLCRunStatus.is_terminal() as the single source of truth for the
terminal/non-terminal split, replacing the scheduler's _NONTERMINAL_STATUSES and
the subscription adapters' ad-hoc `in (COMPLETED, FAILED)` checks. The agent-auth
middleware now delegates to ApiKeyService.validate_key (hash + revoked + expiry)
instead of re-implementing the query/hash — the two can no longer drift.

#9763 — test_invoke_writes_state_file patched builtins.open then asserted the
state file exists on disk (impossible). Dropped the open patch so the file is
written for real to the temp dir; the assertion is now meaningful.

Adds tests for is_terminal() (partition totality) and the auth middleware
(passthrough / 401 / valid-key delegation) — the middleware had no tests before.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

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.

1 participant