Class ReduceBinding

java.lang.Object
ai.badmonkey.agentspaces.agent.reduce.ReduceBinding
All Implemented Interfaces:
AutoCloseable

public final class ReduceBinding extends Object implements AutoCloseable
The runtime behind @SpaceReduce (ISSUE-SpaceReduce ยง9.3): a fold whose accumulator is an entry beside its elements. A step takes one element, invokes the method with the key's current accumulator, and completes the element with the new accumulator as the result, atomically; the previous accumulator is then retired. A JoinTicket per key, taken before a drain and re-armed by completion after it, serializes the steps of one key across reducers; under SpaceReduce.Mode.ORDERED every take goes through the ordered-log coordinator and the log decides the ticket's holder.

Constructed and started by AgentBinder; the step and the side-output dispatch it is given are the binder's method invocation and return handling, so this class never reflects on the agent itself.

  • Constructor Details

    • ReduceBinding

      public ReduceBinding(ReduceBinding.Config config, BiFunction<Object,Object,Object> step, Consumer<Object> sideOutputs, InstantSource clock)
      Parameters:
      config - what the binder resolved from the annotation
      step - invokes the agent's method on (accumulator or null, element) and returns its result
      sideOutputs - the binder's return handling for a fork's other elements
      clock - the binder's clock
  • Method Details

    • name

      public String name()
      The reduce's name, as tickets, accumulators, and the card carry it.
    • start

      public void start()
      Seeds the pending keys from the space, subscribes to the elements, and starts the drain.
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable