Riverbed Memory を使用する
Riverbed Memory は過去のレビュー判断を構造化レコードとして保存し、後続のレビュー実行で参照可能にする仕組みです。
前提条件
- Node.js 22 以上
npm ci済み
エンドツーエンドの使い方
1. eval 実行時にメモリを保存する
npm run eval:all に --persist-memory フラグを付けると、eval 結果が .river/memory/index.json に自動保存されます。
npm run eval:all -- --persist-memory --append-ledger --description "baseline"
実行後、.river/memory/index.json にエントリが追加されます。
2. メモリを手動で追加する
src/lib/riverbed-memory.mjs の API を直接使用してレコードを追加できます。
import { appendEntry } from './src/lib/riverbed-memory.mjs';
appendEntry('.river/memory/index.json', {
id: 'wontfix-silent-catch-utils',
type: 'wontfix',
title: 'utils.mjs の silent catch は意図的',
content: 'エラーログは上位で処理済みのため、catch 内での再 throw は不要。',
metadata: {
createdAt: new Date().toISOString(),
author: 'reviewer',
phase: 'midstream',
tags: ['observability', 'silent-catch'],
confidence: 0.9,
},
context: {
sourcePR: 'https://github.com/example/repo/pull/42',
},
});
3. メモリを検索する
import { loadMemory, queryMemory } from './src/lib/riverbed-memory.mjs';
const index = loadMemory('.river/memory/index.json');
// type でフィルタ
const wontfixEntries = queryMemory(index, { type: 'wontfix' });
// phase + tags でフィルタ
const midstreamSecurity = queryMemory(index, {
phase: 'midstream',
tags: ['security'],
});
4. CI で永続化する(GitHub Artifact)
.github/workflows/riverbed-persist.yml が GitHub Artifact 経由でメモリを永続化します。
# 他のワークフローから呼び出す
jobs:
persist:
uses: ./.github/workflows/riverbed-persist.yml
前回のアーティファクトを自動ダウンロードし、更新後にアップロードします(90 日 retention)。メモリが見つからない場合も正常動作します(stateless fallback)。
レコード型
| type | 用途 |
|---|---|
adr | ADR への紐付け |
review | レビュー結果の記録 |
wontfix | 意図的に対応しない判断 |
pattern | 繰り返し出現するパターン |
decision | 設計判断の記録 |
eval_result | 評価実行結果(--persist-memory で自動生成) |
スキーマ
レコードは schemas/riverbed-entry.schema.json に準拠します。必須フィールド:
id— 一意識別子type— 上記のレコード型content— 本文metadata.createdAt— ISO タイムスタンプmetadata.author— 作成者
関連
- スキーマ定義:
schemas/riverbed-entry.schema.json - インデックススキーマ:
schemas/riverbed-index.schema.json - 永続化ワークフロー:
.github/workflows/riverbed-persist.yml - 背景と設計思想:
pages/explanation/riverbed-memory.md