认证凭据语义
本文档定义了以下模块共用的凭据资格判定与解析语义:
resolveAuthProfileOrderresolveApiKeyForProfilemodels status --probedoctor-auth
目标是让选择阶段和运行时的行为保持一致。
稳定的 Reason Code
okmissing_credentialinvalid_expiresexpiredunresolved_ref
Token 凭据
Token 凭据(type: "token")支持内联 token 和/或 tokenRef。
资格判定规则
- 当
token和tokenRef都不存在时,该 Token 配置不合格。 expires是可选字段。- 如果设置了
expires,它必须是大于0的有限数字。 - 如果
expires无效(NaN、0、负数、非有限值或类型错误),该配置不合格,原因为invalid_expires。 - 如果
expires已过期,该配置不合格,原因为expired。 tokenRef不会绕过expires验证。
解析规则
- 解析器对
expires的处理语义与资格判定一致。 - 对于合格的配置,token 值可以从内联值或
tokenRef获取。 - 无法解析的 ref 会在
models status --probe输出中产生unresolved_ref。
兼容旧版的消息格式
为了脚本兼容性,probe 错误的第一行保持不变:
Auth profile credentials are missing or expired.
人类可读的详细信息和稳定的 reason code 会出现在后续行中。