Class InMemoryGeneratedArtifactStore

java.lang.Object
com.agentforge4j.runtime.InMemoryGeneratedArtifactStore
All Implemented Interfaces:
GeneratedArtifactStore

public final class InMemoryGeneratedArtifactStore extends Object implements GeneratedArtifactStore
Default GeneratedArtifactStore retaining emitted bytes in memory, keyed by run. Enforces run isolation, last-write-wins upsert, and configured per-run bounds; clear(String) releases a run's entries at terminal state.

Bounds fail closed: a write that would exceed maxArtifactsPerRun or whose content exceeds maxContentLength is rejected rather than retained, so a misbehaving run cannot grow the store without limit.

  • Field Details

    • DEFAULT_MAX_ARTIFACTS_PER_RUN

      public static final int DEFAULT_MAX_ARTIFACTS_PER_RUN
      Default maximum number of artifacts retained per run.
      See Also:
    • DEFAULT_MAX_CONTENT_LENGTH

      public static final int DEFAULT_MAX_CONTENT_LENGTH
      Default maximum content length (characters) retained per artifact.
      See Also:
  • Constructor Details

    • InMemoryGeneratedArtifactStore

      public InMemoryGeneratedArtifactStore()
      Creates a store with the default bounds.
    • InMemoryGeneratedArtifactStore

      public InMemoryGeneratedArtifactStore(int maxArtifactsPerRun, int maxContentLength)
      Creates a store with explicit bounds.
      Parameters:
      maxArtifactsPerRun - maximum artifacts retained per run; must be greater than zero
      maxContentLength - maximum content length (characters) per artifact; must be greater than zero
  • Method Details

    • register

      public void register(String runId, String stepId, String path, String content)
      Registers the emitted bytes of a file produced by a step for the given run.
      Specified by:
      register in interface GeneratedArtifactStore
      Parameters:
      runId - non-blank owning run id
      stepId - non-blank producing step id
      path - non-blank requested artifact path
      content - emitted content; must not be null
    • find

      public Optional<String> find(String runId, String path)
      Returns the emitted content for path within runId, if present.
      Specified by:
      find in interface GeneratedArtifactStore
      Parameters:
      runId - non-blank run id
      path - non-blank artifact path
      Returns:
      the content, or empty when no artifact was registered at that path for the run
    • artifacts

      public List<GeneratedArtifact> artifacts(String runId)
      Returns the artifacts registered for runId, in registration order.
      Specified by:
      artifacts in interface GeneratedArtifactStore
      Parameters:
      runId - non-blank run id
      Returns:
      an immutable snapshot (empty when the run has no registered artifacts)
    • remove

      public void remove(String runId, String path)
      Removes the artifact at path for runId, if present. Idempotent (a no-op when the run or path is absent).
      Specified by:
      remove in interface GeneratedArtifactStore
      Parameters:
      runId - non-blank run id
      path - non-blank artifact path to evict
    • clear

      public void clear(String runId)
      Releases all artifacts held for runId. Idempotent.
      Specified by:
      clear in interface GeneratedArtifactStore
      Parameters:
      runId - non-blank run id