Thread per-commitment enforcement level through to the snapshot

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-01 12:38:35 -04:00
parent 7fdcae5d14
commit 41c0a5fbbc
4 changed files with 76 additions and 26 deletions
+7 -1
View File
@@ -12,6 +12,7 @@ import (
"sync"
"time"
"antidrift/internal/domain"
"antidrift/internal/session"
"antidrift/internal/statemachine"
@@ -110,6 +111,7 @@ type commitmentRequest struct {
SuccessCondition string `json:"success_condition"`
TimeboxSecs int64 `json:"timebox_secs"`
AllowedWindowClasses []string `json:"allowed_window_classes"`
Enforce bool `json:"enforce"`
}
func (s *Server) handleCommitment(c *gin.Context) {
@@ -118,7 +120,11 @@ func (s *Server) handleCommitment(c *gin.Context) {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid json"})
return
}
err := s.ctrl.StartManualCommitment(req.NextAction, req.SuccessCondition, time.Duration(req.TimeboxSecs)*time.Second, req.AllowedWindowClasses)
level := domain.EnforcementWarn
if req.Enforce {
level = domain.EnforcementBlock
}
err := s.ctrl.StartManualCommitment(req.NextAction, req.SuccessCondition, time.Duration(req.TimeboxSecs)*time.Second, req.AllowedWindowClasses, level)
if err == nil {
s.armExpiry()
}