You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(llc): consolidate duplicated key-validation, API-key placeholder, and terminal-status checks #9777
Three related duplications in the LLC module, surfaced while implementing the heartbeat run-scoped key lifecycle (#9622/#9623, PR #9772). None are bugs today, but each is a "edit-two-places-in-sync" hazard.
llc/middleware/agent_auth.py hand-rolls the same key-validation query as ApiKeyService.validate_key — key_hash + revoked_at IS NULL + (now) expires_at TTL check — plus an inline hashlib.sha256(...) duplicating services/api_key.py._hash_key.
Note: PR #9772 had to add the expires_at clause to both places to keep them consistent — direct evidence of the hazard (miss one → expired keys accepted = security hole).
Fix: middleware calls ApiKeyService().validate_key(session, raw_key); keep the last_used_at update + request.state wiring in the middleware. Share _hash_key. Add middleware tests (none exist today) before/with the refactor.
2. "<injected-at-runtime>" placeholder duplicated
Defined as _AGENT_API_KEY_PLACEHOLDER in llc/adapters/claude_code_adapter.py but also written as a raw literal in llc/kb/context_builder.py (×2). The adapter skips this exact string when injecting AUTOBOT_LLC_API_KEY — if the builder's literal drifts, the real key leaks/placeholder leaks.
Fix: single shared constant (e.g. llc/config), imported by both.
3. No terminal-status helper on LLCRunStatus
LLCRunStatus (llc/models/enums.py) has no terminal/nonterminal helper. The concept is re-derived ad hoc:
Partially addressed by PR #9811 (merged): the <injected-at-runtime> placeholder is now a single shared constant in llc/config (AGENT_API_KEY_PLACEHOLDER), used by both the producer (HeartbeatContextBuilder) and the adapters. Remaining (this issue stays open): (1) middleware agent_auth.py still re-implements ApiKeyService.validate_key + _hash_key; (2) LLCRunStatus still has no is_terminal() helper (scattered in (COMPLETED, FAILED) checks + scheduler _NONTERMINAL_STATUSES). Both will be done in the next PR.
Activity
fix(llc/adapters): share subprocess prompt+credential handling across…
mrveiss commentedon Jun 9, 2026
Partially addressed by PR #9811 (merged): the
<injected-at-runtime>placeholder is now a single shared constant inllc/config(AGENT_API_KEY_PLACEHOLDER), used by both the producer (HeartbeatContextBuilder) and the adapters. Remaining (this issue stays open): (1) middlewareagent_auth.pystill re-implementsApiKeyService.validate_key+_hash_key; (2)LLCRunStatusstill has nois_terminal()helper (scatteredin (COMPLETED, FAILED)checks + scheduler_NONTERMINAL_STATUSES). Both will be done in the next PR.refactor(llc): consolidate config, terminal-status helper, key valida…
mrveiss commentedon Jun 9, 2026
Fixed in PR #9829 (merged to Dev_new_gui).