| 1 | package event |
| 2 | |
| 3 | import "reasonix/internal/nilutil" |
| 4 | |
| 5 | // WorkspaceMutation is a host-only resource invalidation produced immediately |
| 6 | // after one concrete writer finishes. It is separate from ToolResult ordering |
| 7 | // and from the provider-visible delivery evidence ledger. |
| 8 | type WorkspaceMutation struct { |
| 9 | ToolID string |
| 10 | ToolName string |
| 11 | Paths []string |
| 12 | AllPaths bool |
| 13 | Content bool |
| 14 | Tree bool |
| 15 | WorkingTree bool |
| 16 | GitMeta bool |
| 17 | } |
| 18 | |
| 19 | // WorkspaceMutationSink receives host-only workspace invalidations. Ordinary |
| 20 | // CLI, remote, and provider transports do not implement this capability. |
| 21 | type WorkspaceMutationSink interface { |
| 22 | RecordWorkspaceMutation(WorkspaceMutation) |
| 23 | } |
| 24 | |
| 25 | // RecordWorkspaceMutation forwards invalidation only for sinks that opt in. |
| 26 | // Failed concrete writers still qualify because they may have partially run. |
| 27 | func RecordWorkspaceMutation(s Sink, mutation WorkspaceMutation) { |
| 28 | if nilutil.IsNil(s) { |
| 29 | return |
| 30 | } |
| 31 | if ws, ok := s.(WorkspaceMutationSink); ok { |
| 32 | mutation.Paths = append([]string(nil), mutation.Paths...) |
| 33 | ws.RecordWorkspaceMutation(mutation) |
| 34 | } |
| 35 | } |
| 36 |