feat: add durable safe retries with uncertainty tracking and SDK examples
This commit is contained in:
@@ -29,6 +29,8 @@ type Attempt struct {
|
||||
EndedAt *time.Time `db:"ended_at"`
|
||||
// ErrorCode 稳定错误分类,供恢复策略判断;不得写入敏感原始错误;可为空,表示尚未设置该关联或值。
|
||||
ErrorCode *string `db:"error_code"`
|
||||
// Retryable Worker 对明确失败声明可安全重试;只用于 FAILED,不证明未知效果安全。
|
||||
Retryable bool `db:"retryable"`
|
||||
// Result 已保存的结果或结果引用 JSON;未取得结果时为空。
|
||||
Result core.JSON `db:"result"`
|
||||
// ResultDigest 结果语义摘要,用于识别确认重报与冲突结果;可为空,表示尚未设置该关联或值。
|
||||
|
||||
@@ -14,6 +14,8 @@ type AttemptEvidence struct {
|
||||
Outcome string `db:"outcome"`
|
||||
// ErrorCode 可选稳定错误分类;无错误分类时为空。
|
||||
ErrorCode *string `db:"error_code"`
|
||||
// Retryable 原失败报告的安全重试声明;证据本身不触发重试。
|
||||
Retryable bool `db:"retryable"`
|
||||
// Payload 结果或证据引用 JSON 文本,保留数字精度。
|
||||
Payload core.JSON `db:"payload"`
|
||||
// RequestDigest 结果语义摘要,排除会话身份与原始秘密。
|
||||
|
||||
@@ -22,9 +22,9 @@ func (s TaskState) Terminal() bool {
|
||||
func (s TaskState) CanTransitionTo(next TaskState) bool {
|
||||
switch s {
|
||||
case TaskWaiting:
|
||||
return next == TaskLeased || next == TaskCancelled || next == TaskFailed
|
||||
return next == TaskLeased || next == TaskCancelled || next == TaskFailed || next == TaskNeedsReview
|
||||
case TaskLeased:
|
||||
return next == TaskRunning || next == TaskWaiting || next == TaskCancelled || next == TaskFailed
|
||||
return next == TaskRunning || next == TaskWaiting || next == TaskCancelled || next == TaskFailed || next == TaskNeedsReview
|
||||
case TaskRunning:
|
||||
return next == TaskSucceeded || next == TaskWaiting || next == TaskFailed || next == TaskNeedsReview || next == TaskCancelled
|
||||
case TaskNeedsReview:
|
||||
|
||||
@@ -27,6 +27,8 @@ type Task struct {
|
||||
Payload core.JSON `db:"payload"`
|
||||
// Result 已保存的结果或结果引用 JSON;未取得结果时为空。
|
||||
Result core.JSON `db:"result"`
|
||||
// EffectUncertain 曾有已授权执行的效果尚未核实;重试/超时不能清除,仅权威成功或后续核查可解除。
|
||||
EffectUncertain bool `db:"effect_uncertain"`
|
||||
// PolicySnapshot 受理时冻结的实际生效策略 JSON。
|
||||
PolicySnapshot core.JSON `db:"policy_snapshot"`
|
||||
// RecoverySafety 恢复安全等级;未知值按需要核查处理,不能默认自动重跑。
|
||||
|
||||
Reference in New Issue
Block a user