Skip to content

Secure, Fast, and Extensible Sandbox runtime for AI agents.

Merge main into subject transition fix

leo peinc315e2d06e51
diff --cc components/egress/fastsandbox_actions.go
index c9cd23991,71f0333ec..433daf590
--- a/components/egress/fastsandbox_actions.go
+++ b/components/egress/fastsandbox_actions.go
@@@ -321,28 -241,16 +321,31 @@@ func (s *fastSandboxPolicyServer) apply
}
s.rehydrateVaultReload(subj, fence, seed, policyDegraded)
}
+ setBindingStarted := time.Now()
+ installStarted := time.Now()
+ // Record even failed first installs: partial kernel effects otherwise have
+ // no network identity for a later same-fence retry or changed-fence rebind.
+ s.recordBindingState(subj, att)
+ var victims []subject.Subject
state, err := s.reg.RegisterAndEnforce(subj, subject.SubjectKey{SourceIP: att.IP}, fence, func() error {
return s.OnRegistered(subj, att)
- }, s.takeoverStaleSubject)
+ }, func(stale subject.Subject) error {
+ victims = append(victims, stale)
+ return s.takeoverStaleSubject(stale)
+ })
+ // Callback teardown never takes mu. Only purge actual evictions after the
+ // registry lock is released, even if successor enforcement failed. The
+ // action gate prevents a victim being re-registered before this purge.
+ for _, victim := range victims {
+ if _, exists := s.reg.Fence(victim); !exists {
+ s.dropSubjectState(victim)
+ }
+ }
if err != nil {
return http.StatusInternalServerError, fmt.Errorf("deny-first install: %w", err)
}
+ denyFirstInstall := time.Since(installStarted)
- s.recordBindingState(subj, att, fence)
+ s.recordRegisteredFence(subj, fence)
if env.Binding.IsRemoval() {
// Binding removed from a still-live sandbox: drop the pending policy
// (a re-added binding gets a fresh input — never apply the removed
@@@ -370,8 -278,9 +374,10 @@@
log.Errorf("subject %s: binding policy commit failed: %v", subj, err)
return http.StatusInternalServerError, fmt.Errorf("binding policy commit: %w", err)
}
+ s.finishRebind(subj, token)
- log.Infof("subject %s: SET_BINDING applied (state=%s)", subj, state)
+ policyCommit := time.Since(policyStarted)
+ log.Infof("subject %s: SET_BINDING applied (state=%s) total=%dms denyFirstInstall=%dms policyCommit=%dms",
+ subj, state, time.Since(setBindingStarted).Milliseconds(), denyFirstInstall.Milliseconds(), policyCommit.Milliseconds())
return http.StatusOK, nil
}