Skip to content

feat: AI Research OS — 状態・記憶・監査の運用系 - #8

Draft
codowave wants to merge 14 commits into
mainfrom
claude/ai-research-audit-system-cGz3a
Draft

feat: AI Research OS — 状態・記憶・監査の運用系#8
codowave wants to merge 14 commits into
mainfrom
claude/ai-research-audit-system-cGz3a

Conversation

@codowave

Copy link
Copy Markdown
Owner

Summary

  • research/ — 9ディレクトリの「思考のGit」構造(inbox/hypotheses/observations/verified/contradictions/ai-comparisons/phase-transitions/glossary/timeline)
  • research_os/ — Python CLIパッケージ(6サブコマンド、全てClaude API使用)
  • .claude/skills/ — 5つの再利用可能プロンプトスキル
  • CLAUDE.md — Claude Codeへの運用指示(ディレクトリ意味、CLIコマンド、安全境界)

CLIコマンド

python -m research_os classify research/inbox/note.md   # 自動分類+front-matter付与
python -m research_os audit output.md --source gpt       # 6種の論理欠陥検出
python -m research_os contradict                         # 矛盾ペア検出
python -m research_os compare research/ai-comparisons/q.md  # AI比較表
python -m research_os timeline                           # 時系列フェーズ遷移
python -m research_os glossary                           # 用語辞典更新

Audit 検出項目

欠陥 説明
logical_leap 論理飛躍
circular_reasoning 再帰的自己正当化(AだからA)
rhetorical_disguise 言い換えによる新規性の偽装
missing_evidence 根拠欠落
over_personification AIの過剰人格化
consistency_drift 文書内部の整合性崩壊

Test plan

  • python -m research_os --help でヘルプ表示確認
  • ANTHROPIC_API_KEY 設定後、classify --dry-run で分類結果確認
  • audit でサンプルテキストの監査レポート確認
  • research/ ディレクトリが gitignore されていないことを確認

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA


Generated by Claude Code

research/ ディレクトリ(思考のGit)、research_os CLIパッケージ、
.claude/skills/ の5スキル、CLAUDE.md 運用指示を追加。

- research_os classify: inbox ノートをClaude APIで自動分類+front-matter付与
- research_os audit: 6種の論理欠陥(飛躍/循環/偽装/根拠欠落/人格化/整合崩壊)を検出
- research_os contradict: ディレクトリ横断の矛盾ペア検出
- research_os compare: 複数AI応答の構造比較表生成
- research_os timeline: 時系列フェーズ遷移の可視化
- research_os glossary: 用語辞典の自動生成・更新

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces "AI Research OS," a suite of Python-based CLI tools and Claude skills designed to manage, audit, and analyze research data within a structured repository. Key features include automated note classification, logical audit of AI-generated content, contradiction detection across research entries, and the generation of glossaries and timelines. Review feedback identified several critical improvements: an invalid model name (claude-sonnet-4-6) must be corrected to a valid Anthropic identifier across all modules, and the manual YAML parsing in the classifier should be replaced with a robust library. Additionally, suggestions were made to ensure directory existence before file writes, relax character limits when processing entries for contradiction detection, and refine directory detection logic in the glossary builder.

Comment thread research_os/auditor.py

client = anthropic.Anthropic(api_key=api_key)
msg = client.messages.create(
model="claude-sonnet-4-6",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

claude-sonnet-4-6 というモデル名は Anthropic API に存在しません。現時点で最新の Sonnet モデルを使用する場合は claude-3-5-sonnet-latest または claude-3-5-sonnet-20241022 を指定してください。この修正は他のファイル(classifier.py, comparator.py, contradiction_detector.py, glossary_builder.py, timeline_tracker.py)にも同様に適用する必要があります。

Suggested change
model="claude-sonnet-4-6",
model="claude-3-5-sonnet-latest",

Comment thread research_os/classifier.py
Comment on lines +60 to +63
for line in fm_block.splitlines():
if ":" in line:
k, _, v = line.partition(":")
fm[k.strip()] = v.strip()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

手動での YAML パースは、リスト形式(tags: [tag1, tag2])や複雑な値を含む場合に正しく処理できない可能性があります。このリポジトリのスキーマではタグをリストとして扱っているため、PyYAML などの標準的なライブラリを使用するか、より堅牢なパース処理を検討してください。

Comment thread research_os/classifier.py
print(new_content)
return

target_path.write_text(new_content, encoding="utf-8")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

出力先ディレクトリが存在しない場合、write_textFileNotFoundError をスローします。書き込み前に target_path.parent.mkdir(parents=True, exist_ok=True) を実行して、ディレクトリの存在を保証することを推奨します。

Suggested change
target_path.write_text(new_content, encoding="utf-8")
target_path.parent.mkdir(parents=True, exist_ok=True)
target_path.write_text(new_content, encoding="utf-8")

if md.name == ".gitkeep":
continue
text = md.read_text(encoding="utf-8")
entries.append({"file": md.name, "dir": d.name, "content": text[:800]})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

エントリの内容を先頭 800 文字に制限していますが、研究ノートの重要な主張や矛盾が後半に含まれている場合、検出に失敗する可能性があります。Claude 3.5 Sonnet 等の長いコンテキストを扱えるモデルを使用しているため、制限を緩和するか、重要なセクションを抽出して渡すことを検討してください。

merged = {"terms": sorted(existing_terms.values(), key=lambda t: t["term"])}

output_dir = out or GLOSSARY_DIR
if isinstance(output_dir, Path) and output_dir.suffix == "":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

output_dir.suffix == "" によるディレクトリ判定は、拡張子のないファイル名と区別できないため不確実です。output_dir.is_dir() を使用するか、パスの性質をより明示的に扱う方法が適切です。

claude added 2 commits May 23, 2026 23:27
speculative / verification_required: mechanism_mapping, mathematical_analogy, textual_comparison

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
biblical_correspondence 辞典とAttention概念の照合候補を抽出する verify サブコマンドを追加。
textual_comparison はAPI不要、mechanism_mapping は Claude API 使用。

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
codowave added a commit that referenced this pull request May 23, 2026
* feat: data bootstrap + health check + Codex P1 regression tests (PR #8)

1. scripts/bootstrap_morph_data.sh
   morphhb (sparse clone, wlc/ only) と morphgnt を data/ 配下に配置する。
   データなしでもアプリは正常動作する(unavailable を返すのが正しい挙動)。

2. GET /api/lexicon/health
   morphhb/morphgnt の配置状態、correspondence_index のエントリ数、
   verify_verse のサニティチェック結果を返す。
   データ未配置でも 200 — "missing" は故障ではなく状態の記述。

3. biblical_correspondence/tests/test_lexicon_health.py (22 tests)
   - verify_verse が unavailable 時に contains=None を返すことを固定(Codex P1 回帰防止)
   - not_found と unavailable が混在しないことを各ケースで確認
   - correspondence_lookup の三状態(found/not_found/unavailable)を固定
   - /api/lexicon/health エンドポイントの HTTP 応答を固定
   全 22 テスト、データ未配置環境でパス。

4. README_DATA.md
   「データなし ≠ 故障」「unavailable ≠ not_found」を明記。
   三状態の意味・bootstrap 手順・ライセンスを記載。

https://claude.ai/code/session_017WKYFbVsWhWZA3M8Jc1eKs

* fix: bootstrap copy layout for morph data

cp -r src/wlc dest/wlc は dest/wlc が既存の場合 dest/wlc/wlc/ になる。
mkdir -p + cp -r src/wlc/. dest/wlc/ 形式に統一し、
実行回数・dest の存在状態に依らず冪等にする。morphgnt も同様。

https://claude.ai/code/session_017WKYFbVsWhWZA3M8Jc1eKs

* fix: make unavailable tests deterministic (env isolation)

setdefault は環境変数が既に設定されていると上書きしない。
実環境に morphhb が配置済みの場合、Codex P1 回帰テストが
unavailable ではなく found を返し、バグを見逃す。

os.environ["MORPHHB_PATH"] / ["MORPHGNT_PATH"] の強制代入に変更し、
このテストファイルを外部環境から完全に独立させる。
回帰防止テストは、環境依存をゼロにしないと意味がない。

https://claude.ai/code/session_017WKYFbVsWhWZA3M8Jc1eKs

* fix: tighten health loader error handling

except Exception: pass はログも状態フラグもなく全エラーを飲む。
JSON パースエラーとファイル読み取りエラーを別々に捕捉し、
ログに記録した上でレスポンスの correspondence_index.error に含める。
entry_count=0 のまま通過するが、原因が response で可視になる。

https://claude.ai/code/session_017WKYFbVsWhWZA3M8Jc1eKs

---------

Co-authored-by: Claude <noreply@anthropic.com>
claude added 11 commits May 23, 2026 23:45
hyp-001の textual_comparison を falsification モードで実行し obs-001 として保存。
influx 系エントリは反証材料になり得ることを明記。
hyp-001 に verification_completed と related_observations を追記。

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
directionality / hierarchy / reduction_risk を必須評価軸として組み込み。
overall_verdict, candidate_upgrade_condition, structural_isomorphism_score を出力。
system prompt: 差異優先・還元リスク明示。

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
読解順序: reduction_risk → directionality → hierarchy → candidate_upgrade_condition → overall_verdict
判定原則: 「類比が残るかではなく、類比が何を壊さないかを見る」

- reduction_risk: reductive → partial_analogy でも no_upgrade
- weak_analogy + metaphorical + 差異明示 → candidate_maintained
- partial_analogy + 2軸 structural_difference → conditional_candidate

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
読解順序どおり先頭に表示:
  adoption_ruling.decision
  candidate_upgrade_condition
  failure_points (具体的な構造的失敗点を列挙)
  reduction_risk.verdict

_collect_failure_points: 3軸 + counter_evidence + key_asymmetry から収集
_format_ruling_summary: サマリーブロックを本文の前に出力

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
AI文言がそのまま入る failure_points を確定判定と誤読しないための柵。

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
[dry-run]
- API呼び出しより前に分岐。dry_run=True は外部送信なし・書き込みなし。
- 送信予定ペイロード全文(system + user_message)を stdout に表示。

[プロンプト構造]
- _MECHANISM_PROMPT_TEMPLATE: hyp-001本文を動的注入。仮説テキスト外の前提を注入しない。
- 検査候補軸を「実装者が設定した仮説的検査軸 — 自明な前提ではない」と明示ラベル。
- swedenborg_analog → correspondence_status に廃止・置き換え。
- 値: confirmed_correspondence / possible_correspondence / weak_analogy /
       structural_mismatch / no_correspondence / requires_source_check
- what_prompt_assumed フィールドでプロンプトが持ち込んだ前提を自己申告させる。
- axis_assessments.hypothesis_says で仮説テキストの沈黙を明示できるようにする。

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
LLMの自己申告は暗黙に通過した前提を返せない(言語化できれば暗黙でない)。
前提点検のゲートをLLMの内部からプロンプト本文の外部読解に移す。

- _IMPLEMENTER_DECLARED_PREMISES: 実装者が外部から明示する前提リスト(Python定数)
- payload_preview.implementer_declared_premises: dry-run時に表示、前提点検の主体
- payload_preview.premise_audit_note: what_llm_reports_as_assumed の限界を明記
- CLAUDE.md: what_llm_reports_as_assumed を補助情報として読む運用ルールを追記

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
- status: unavailable なら保存前に sys.exit(1)(APIキーなし保存を防ぐ)
- _next_obs_id(): obs-XXX.md を走査して連番を自動付番(ハードコード廃止)
- _build_observation_md(): task分岐でmechanism_mappingの結果を正しく展開
  - component_assessments / axis_assessments / failure_points を記録
  - what_llm_reports_as_assumed を「自己申告 — 補助のみ」ラベルで明示隔離

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
7項目の読解順序と、合格条件・不合格条件を運用ルールとして固定。
特に不合格条件: what_llm_reports_as_assumed の根拠化、unresolved消失、
hyp-001外主張の追加を明示。

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
obs-002.md読解の目的を「成功確認」でなく「ドリフト検査」として明示。
- 観測点A: no_correspondence の維持
- 観測点B: hypothesis_says にない接続の滑らか生成
- 観測点C: what_llm_reports_as_assumed の自己正当化膨張
- fp-2: 逃げ道的アナロジー復活パターン(「比喩的には〜」等)の命名と記録基準

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
棄却でなく隔離として機能させるための説明と、
candidates → provisional → stable の分類パイプラインを文書化。

https://claude.ai/code/session_015ew48Qv8JWVMzSotLA8fPA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants