认证凭据语义

本文档定义了以下模块共用的凭据资格判定与解析语义:

  • resolveAuthProfileOrder
  • resolveApiKeyForProfile
  • models status --probe
  • doctor-auth

目标是让选择阶段和运行时的行为保持一致。

稳定的 Reason Code

  • ok
  • missing_credential
  • invalid_expires
  • expired
  • unresolved_ref

Token 凭据

Token 凭据(type: "token")支持内联 token 和/或 tokenRef

资格判定规则

  1. tokentokenRef 都不存在时,该 Token 配置不合格。
  2. expires 是可选字段。
  3. 如果设置了 expires,它必须是大于 0 的有限数字。
  4. 如果 expires 无效(NaN0、负数、非有限值或类型错误),该配置不合格,原因为 invalid_expires
  5. 如果 expires 已过期,该配置不合格,原因为 expired
  6. tokenRef 不会绕过 expires 验证。

解析规则

  1. 解析器对 expires 的处理语义与资格判定一致。
  2. 对于合格的配置,token 值可以从内联值或 tokenRef 获取。
  3. 无法解析的 ref 会在 models status --probe 输出中产生 unresolved_ref

兼容旧版的消息格式

为了脚本兼容性,probe 错误的第一行保持不变:

Auth profile credentials are missing or expired.

人类可读的详细信息和稳定的 reason code 会出现在后续行中。