Wrapper context/artifact_store.py re-implements core SDK FileSystemArtifactStore

オープン
#5,651 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
22/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
静か
技術スタック
python
領域
backend

調査の方向性

Compare the two FileSystemArtifactStore classes in src/praisonai/praisonai/context/artifact_store.py and src/praisonai-agents/praisonaiagents/context/artifact_store.py, focusing on the shared store, tail, grep, chunk, delete and list methods. First decide whether core can take a configurable base_dir and layout, since the wrapper cannot subclass it otherwise. Done means the wrapper keeps only the run-scoped layout, get_run_dir and cleanup_run, and the praisonai context CLI tests still pass unchanged.

索引モデルが issue の本文から書いたものです。

説明

claude

Summary

The praisonai wrapper ships a second FileSystemArtifactStore (~17.6 KB) that re-implements the same ArtifactStoreProtocol the core SDK already implements, against the same core helper primitives. The two stores differ only in on-disk layout. This is duplicated logic the wrapper could obtain by parametrising/subclassing the core store. This is a DRY/wrapper-health finding — not a request to remove the praisonai context artifact capability.

Current behaviour

Wrapper: src/praisonai/praisonai/context/artifact_store.py:31 class FileSystemArtifactStore

  • Methods: store (150), tail (251), grep (319), chunk (371), delete (403), list_artifacts (425), get_run_dir (499), cleanup_run (503)
  • Layout: ~/.praison/runs/{run_id}/artifacts/{agent_id}/
  • Imports the same primitives from core: from praisonaiagents.context.artifacts import ArtifactRef, ArtifactMetadata, GrepMatch, QueueConfig, compute_checksum, generate_summary (lines 19-26)

Core SDK: src/praisonai-agents/praisonaiagents/context/artifact_store.py:28 class FileSystemArtifactStore

  • Implements ArtifactStoreProtocol; methods store (70), tail (198), grep (244), chunk (292), delete (322), list_artifacts (345), cleanup_old_artifacts (426)
  • Layout: ~/.praisonai/artifacts/{agent_id}/{run_id}/
  • Imports the same primitives from .artifacts

Live wrapper consumers (so this is a consolidation candidate, not dead code): cli/commands/context.py:284/337/368/393, context/setup.py:12, context/queue.py:33.

Why it matters

~17 KB of near-identical filesystem store/tail/grep/chunk/delete/list logic maintained twice, against the same protocol and the same core helper functions. Behavioural fixes (secret redaction, checksum verification, grep/tail/chunk edge cases) must be applied in both copies or they drift.

Category

Duplicate

Capability preserved

  • The praisonai context CLI commands keep working byte-for-byte.
  • The wrapper's distinct run-scoped on-disk layout (~/.praison/runs/{run_id}/artifacts/{agent_id}/) and its base_dir parameter are preserved — the layout difference is the whole reason a separate class exists today.
  • get_run_dir / cleanup_run (run-scoped helpers the core store does not expose) remain available.

Proposed approach

Make the core FileSystemArtifactStore parametrisable on base directory and path layout (it already accepts helpers it shares with the wrapper), then have the wrapper subclass it to inject the run-scoped layout and the get_run_dir/cleanup_run helpers — removing the duplicated store/tail/grep/chunk/delete/list bodies. Non-breaking; the wrapper symbol praisonai.context.FileSystemArtifactStore and its base_dir= constructor keep the same signature.

Resolution sketch

# Before: wrapper carries a full second copy of store/tail/grep/chunk/delete/list.
class FileSystemArtifactStore:
    def store(self, ...): ...   # ~17KB duplicated against the same protocol/primitives

# After: subclass core; keep only the layout + run-scoped extras.
from praisonaiagents.context.artifact_store import FileSystemArtifactStore as _CoreStore

class FileSystemArtifactStore(_CoreStore):
    def __init__(self, base_dir="~/.praison/runs"):
        super().__init__(base_dir=base_dir, layout="{run_id}/artifacts/{agent_id}")
    def get_run_dir(self, run_id): ...
    def cleanup_run(self, run_id): ...

(Requires the small core change of accepting a configurable base_dir/layout; if core cannot take that in this cycle, keep the wrapper copy and track the consolidation.)

Layer placement

  • Primary layer: wrapper (consume core instead of re-implementing)
  • Touches core: small, additive — make core store's base dir / layout configurable
  • 3-way surface (CLI + YAML + Python): preserved

Severity

Medium — maintenance duplication of ~17 KB against an existing core protocol; no user-facing change intended.

Validation

Confirmed the wrapper class is live (consumers listed above), implements the same protocol as core, and imports the identical core primitives — i.e. genuine parallel re-implementation, not an independent concern. The only material difference is on-disk layout, which the proposed approach preserves.

Keep unchanged

  • The run-scoped storage layout and base_dir default.
  • Secret redaction, checksum verification, and tail/grep/chunk behaviour as currently observed by praisonai context.
  • context/queue.py and context/setup.py wiring and their public call sites.
主要言語
Python
スター
9.3k
フォーク
1.5k
平均マージ
1日 5時間
マージ済み PR(30日)
520

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

MervinPraison/PraisonAI のほかの issue

MervinPraison/PraisonAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。