| 213 | if c.Engine == nil { |
| 214 | return "", errors.New("memory fabric engine is unavailable") |
| 215 | } |
| 216 | payload := c.incrementalFabricContext(state) |
| 217 | if len(payload.Messages) == 0 { |
| 218 | c.advanceFabricCursor(payload) |
| 219 | return "", nil |
| 220 | } |
| 221 | return c.runFabricExtraction(ctx, payload) |
| 222 | } |
| 223 | |
| 224 | // IngestMessages durably records the next raw evidence batch without invoking |
| 225 | // the Semantic Compiler. It is used while sealing a context and by importers. |
| 226 | func (c *ExtractionController) IngestMessages(ctx context.Context, state *AgentState) (int, error) { |
| 227 | if state == nil { |
| 228 | return 0, errors.New("agent state is required") |
| 229 | } |
| 230 | if !c.Config.LongTermMemoryEnabled || !isFabricMemoryBackend(c.Config) { |
| 231 | return 0, errors.New("Memory Fabric is required for evidence ingestion") |
| 232 | } |
| 233 | payload := c.incrementalFabricContext(state) |
| 234 | if len(payload.Messages) == 0 { |
| 235 | c.advanceFabricCursor(payload) |
| 236 | return 0, nil |
| 237 | } |
| 238 | return c.ingestFabricEvents(ctx, payload) |
| 239 | } |
| 240 | |
| 241 | func (c *ExtractionController) ingestFabricEvents(ctx context.Context, payload *extractionContext) (int, error) { |
| 242 | if c.Engine == nil { |
| 243 | return 0, errors.New("memory fabric engine is unavailable") |
| 244 | } |
| 245 | events := c.fabricEvents(payload) |
| 246 | if len(events) == 0 { |
| 247 | c.advanceFabricCursor(payload) |
| 248 | return 0, nil |
| 249 | } |
| 250 | result, err := c.Engine.AppendEvents(ctx, events, |