| 1 | package agent |
| 2 | |
| 3 | import "reasonix/internal/plancontract" |
| 4 | |
| 5 | // SetPlanContract records the approved plan this turn executes, or clears it |
| 6 | // when the turn runs without one. The coordinator sets it before every executor |
| 7 | // run so a turn never inherits the previous turn's plan. |
| 8 | func (a *Agent) SetPlanContract(plan *plancontract.Plan) { |
| 9 | if a == nil { |
| 10 | return |
| 11 | } |
| 12 | a.sess.todoMu.Lock() |
| 13 | defer a.sess.todoMu.Unlock() |
| 14 | if plan == nil { |
| 15 | a.planContract = nil |
| 16 | return |
| 17 | } |
| 18 | copied := *plan |
| 19 | a.planContract = &copied |
| 20 | } |
| 21 | |
| 22 | func (a *Agent) planContractSnapshot() *plancontract.Plan { |
| 23 | if a == nil { |
| 24 | return nil |
| 25 | } |
| 26 | a.sess.todoMu.Lock() |
| 27 | defer a.sess.todoMu.Unlock() |
| 28 | if a.planContract == nil { |
| 29 | return nil |
| 30 | } |
| 31 | copied := *a.planContract |
| 32 | return &copied |
| 33 | } |
| 34 |