Class DefaultHistoryService

java.lang.Object
cloud.opencode.base.flow.internal.DefaultHistoryService
All Implemented Interfaces:
HistoryService

public final class DefaultHistoryService extends Object implements HistoryService
Default HistoryService implementation — delegates to the repository with an optional engine-side authorisation check. 默认 HistoryService 实现 —— 委托给仓储并支持引擎侧鉴权。

R3 SEC P0-3: when a non-no-op CurrentUserProvider is wired, timeline(String) / findByUser(String, int, int) / findByTaskId(String) are restricted to participants of the instance (initiator / current or past assignee). With CurrentUserProvider.NO_OP the engine reverts to the legacy permissive behaviour and assumes the host enforces auth on its API boundary.

R3 SEC P0-3:装配真实 CurrentUserProvider 时 timeline/findByUser/findByTaskId 仅允许实例参与者读取;NO_OP 则维持兼容模式。

Since:
JDK 25, opencode-base-flow V1.0.5
Author:
Leon Soo
  • Constructor Details

    • DefaultHistoryService

      public DefaultHistoryService(FlowRepository repo)
      Construct the service with no engine-level authz (legacy / test mode). 构造服务(无引擎级鉴权——兼容/测试模式)。
      Parameters:
      repo - persistence facade — 持久化门面
      Since:
      JDK 25, opencode-base-flow V1.0.5
    • DefaultHistoryService

      public DefaultHistoryService(FlowRepository repo, CurrentUserProvider currentUser)
      Construct the service with engine-level authz enforced via the given CurrentUserProvider. 构造服务并启用引擎级鉴权。
      Parameters:
      repo - persistence facade — 持久化门面
      currentUser - current-user SPI — 当前用户 SPI
      Since:
      JDK 25, opencode-base-flow V1.0.5
  • Method Details

    • timeline

      public List<HistoryRecord> timeline(String instanceId)
      Description copied from interface: HistoryService
      Returns the full chronological timeline (earliest first) for an instance. 返回实例的完整时间线(按时间升序)。
      Specified by:
      timeline in interface HistoryService
      Parameters:
      instanceId - instance id — 实例 ID
      Returns:
      chronological history — 历史
    • findByUser

      public List<HistoryRecord> findByUser(String userId, int page, int size)
      Description copied from interface: HistoryService
      Paginated history rows operated by the given user. 分页查询某用户的历史记录。
      Specified by:
      findByUser in interface HistoryService
      Parameters:
      userId - operator user id — 操作人
      page - zero-based page — 页码(0 起)
      size - page size — 每页大小
      Returns:
      history rows — 历史
    • findByTaskId

      public Optional<HistoryRecord> findByTaskId(String taskId)
      Description copied from interface: HistoryService
      Returns the single history row tied to the given task id (if any). 返回关联指定 task 的历史记录(若有)。
      Specified by:
      findByTaskId in interface HistoryService
      Parameters:
      taskId - task id — 任务 ID
      Returns:
      history row (Optional) — 历史记录(Optional)