fix(prime): send with the vault credential for a vault-served fallback - #197
Open
iceteaSA wants to merge 1 commit into
Open
fix(prime): send with the vault credential for a vault-served fallback#197iceteaSA wants to merge 1 commit into
iceteaSA wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
1 issue found across 3 files
Confidence score: 5/5
- In
packages/opencode/src/tests/index.test.ts, a failed assertion or await can leave the log sink anddebuglevel installed, contaminating later tests and making failures order-dependent; move cleanup into guaranteed teardown such asafterEachor afinallyblock.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/opencode/src/tests/index.test.ts">
<violation number="1" location="packages/opencode/src/tests/index.test.ts:19896">
P3: The log sink and debug level installed here are reset only at the end of the test body. If any expect or await before `__setLogTestSink(null)` fails, the sink and 'debug' level leak into every later test in the file, since `afterEach` only restores fetch/setInterval. Wrap the sink/level setup and teardown in try/finally so a failure cannot contaminate the rest of the suite.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| const { __setLogTestSink, setLogLevel } = await import( | ||
| '@cortexkit/anthropic-auth-core' | ||
| ) | ||
| setLogLevel('debug') |
There was a problem hiding this comment.
P3: The log sink and debug level installed here are reset only at the end of the test body. If any expect or await before __setLogTestSink(null) fails, the sink and 'debug' level leak into every later test in the file, since afterEach only restores fetch/setInterval. Wrap the sink/level setup and teardown in try/finally so a failure cannot contaminate the rest of the suite.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/opencode/src/tests/index.test.ts, line 19896:
<comment>The log sink and debug level installed here are reset only at the end of the test body. If any expect or await before `__setLogTestSink(null)` fails, the sink and 'debug' level leak into every later test in the file, since `afterEach` only restores fetch/setInterval. Wrap the sink/level setup and teardown in try/finally so a failure cannot contaminate the rest of the suite.</comment>
<file context>
@@ -19682,6 +19715,397 @@ describe('claude-prime direct request', () => {
+ const { __setLogTestSink, setLogLevel } = await import(
+ '@cortexkit/anthropic-auth-core'
+ )
+ setLogLevel('debug')
+ __setLogTestSink((record: any) => records.push(record))
+ mgr.options.refreshQuota = async () => ({ quota: dueQuota, fresh: true })
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
sendPrimerefreshed a fallback account and then sent the prime request withcurrent.access. For a vault-served fallback the refresh is a deliberate no-op (v1.22.0 custody: the vault owns rotation), socurrent.accessis the frozen sidecar token, which the vault's first rotation revoked. Live result since custody took overwork-alt: every prime tick from every plugin process logsSame defect class as the quota-poll fix in v1.22.0 (usage endpoint polled with the sidecar token); prime's send path was missed. Harmless beyond the noise, but the account was never primed.
Fix
refreshAccountcall.{ ok: false, reason: 'vault-cold' }, routed to the quiet skip branch inPrimeManager(debug, existing backoff). Never aprime fire failedwarn.credential.report_auth_failure(reporter_source: "direct") with therecord_versionof the credential the prime was sent with, captured at send time. A re-peek after the response could name a version a tick refresh already superseded, which the vault silently ignores by design. Deduped through the same(handle, version)map the request path uses. A sidecar-token 401 is never reported.Tests
Four regressions in
index.test.ts, each proven red first:account.accessagainvault-coldto the warn branchprime fire failedlogged oncerecord_versionGates: core build, root
bun run test1726/0 (169 core + 1557 opencode), typecheck, format:check, biome. Cross-family review (MiniMax M3): APPROVE 0 must / 2 style nits.Vault-side consequence (confirmed with the Claustrum side): a spurious prime 401 costs one extra rotation per 5 h window; a genuine one latches
needs_reauthand the sidebarvaultReauthstate agrees.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by cubic
Fixes prime requests for vault-served fallback accounts sending with the revoked sidecar token, which caused a 401 warn on every tick. Prime now sends with the resident vault credential instead.
Bug Fixes
Written for commit 69139c0. Summary will update on new commits.