← ドキュメント一覧/アーキテクチャ

組織設計原則5原則

組織設計原則5原則

概要: 組織設計原則5原則は、効果的な組織運営の基本原則をシステム実装に適用したものです。責任・権限の明確化、結果重視、階層の明確化、誤解・錯覚の排除、感情的判断の排除により、自律型AI開発システムの客観性と効率性を保証します。

対象読者: アーキテクト / プロジェクトマネージャー / システム管理者 所要時間: 15分 前提知識: システム全体像, Agent階層システム


5原則概要

原則実装内容KPI目標
1. 責任と権限の明確化Agent階層・Label体系・CODEOWNERS担当者アサイン率100%
2. 結果重視quality_score・KPI自動収集AI Task成功率95%+
3. 階層の明確化Coordinator-Specialist階層エスカレーション正答率100%
4. 誤解・錯覚の排除構造化プロトコル・完了条件チェック完了条件明示率100%
5. 感情的判断の排除数値ベース判定(80点基準等)データ駆動判定実施率100%

原則1: 責任と権限の明確化

目的

「誰が何をする権限を持つか」を明確にし、責任の曖昧さを排除する。

実装

1.1 Agent階層

agent_hierarchy:
  coordinator_layer:
    - CoordinatorAgent:
        responsibility: タスク分解・Agent統括・並行実行制御
        authority: リソース配分・Agent割り当て
        escalation_to: TechLead, PO

  specialist_layer:
    - CodeGenAgent:
        responsibility: AI駆動コード生成・テスト自動生成
        authority: 実装レベル決定
        escalation_to: TechLead

    - ReviewAgent:
        responsibility: 静的解析・セキュリティスキャン・品質判定
        authority: 品質合否判定(80点基準)
        escalation_to: TechLead, CISO

    - DeploymentAgent:
        responsibility: CI/CD実行・デプロイ・Rollback
        authority: Staging環境デプロイ
        escalation_to: CTO(本番環境)

詳細はAgent階層システムを参照。

1.2 Label体系

GitHub Labelsを使用して責任者を明示:

カテゴリLabel責任範囲
責任者👤担当-開発者実行権限
👥担当-テックリード確認権限
👑担当-PO決裁権限
🤖担当-AI Agent自動実行

自動付与:

// IssueAgent自動Label付与
export class IssueAgent extends BaseAgent {
  async analyzeIssue(issue: Issue): Promise<AnalysisResult> {
    // Severity評価
    const severity = await this.evaluateSeverity(issue);

    // 責任者Label自動付与
    const labels = [];

    if (severity === 'Sev.1-Critical') {
      labels.push('👑担当-PO');  // 決裁権限必要
    } else if (severity === 'Sev.2-High') {
      labels.push('👥担当-テックリード');  // 確認権限
    } else {
      labels.push('👤担当-開発者');  // 実行権限
    }

    return { labels };
  }
}

1.3 CODEOWNERS

ファイル単位の責任者を自動割り当て:

# .github/CODEOWNERS
agents/                 @ai-agent-team
src/                    @dev-team
.ai/                    @ai-operations-lead
.github/workflows/      @devops-team
docs/                   @tech-writer-team

KPI

  • 担当者アサイン率: 100% (全IssueにLabel自動付与)
  • CODEOWNERS適合率: 100% (PR作成時に自動割り当て)

原則2: 結果重視

目的

プロセスではなく「何を達成したか」を評価し、客観的な成果測定を実現する。

実装

2.1 Quality Score

ReviewAgentによる客観的品質評価:

export class ReviewAgent extends BaseAgent {
  async reviewCode(code: Code): Promise<ReviewResult> {
    let score = 100;

    // 静的解析
    const eslintErrors = await this.runESLint(code);
    score -= eslintErrors.length * 20;

    // TypeScript型チェック
    const tsErrors = await this.runTypeCheck(code);
    score -= tsErrors.length * 30;

    // セキュリティスキャン
    const vulnerabilities = await this.runSecurityScan(code);
    score -= vulnerabilities.critical * 40;
    score -= vulnerabilities.high * 20;
    score -= vulnerabilities.medium * 10;

    return {
      score,
      passed: score >= 80,  // 80点基準
      issues: [...eslintErrors, ...tsErrors, ...vulnerabilities]
    };
  }
}

合格基準:

quality_gate:
  threshold: 80点
  criteria:
    - total_score: ≥80
    - critical_vulnerabilities: 0
    - typescript_errors: 0
    - test_coverage: ≥80%

2.2 KPI自動収集

kpi_collection:
  frequency: "6時間ごと"
  metrics:
    - ai_task_success_rate: "成功タスク数 / 総タスク数"
    - average_execution_time: "総実行時間 / タスク数"
    - quality_score_avg: "品質スコアの平均"
    - escalation_count: "エスカレーション発生回数"

  storage:
    - format: JSON
    - location: ".ai/parallel-reports/"
    - retention: "30日"

自動収集スクリプト:

# 6時間ごとに実行(cron)
npm run kpi:collect

# 出力例: .ai/parallel-reports/kpi-20251010-1200.json
{
  "timestamp": "2025-10-10T12:00:00Z",
  "ai_task_success_rate": 0.97,
  "average_execution_time": 180000,
  "quality_score_avg": 92,
  "escalation_count": 2
}

2.3 自動レポート生成

# ダッシュボード自動生成
npm run dashboard:generate

# 出力: docs/index.html(GitHub Pagesで公開)

KPI

  • AI Task成功率: 97% (目標: 95%以上)
  • 品質スコア平均: 92点 (目標: 85点以上)

原則3: 階層の明確化

目的

意思決定階層を明確にし、適切なエスカレーション経路を確立する。

実装

3.1 3層アーキテクチャ

hierarchy:
  layer_1_human:
    role: 戦略決定・承認
    members: [TechLead, PO, CISO]
    authority:
      - アーキテクチャ決定
      - 本番デプロイ承認
      - セキュリティポリシー決定

  layer_2_coordinator:
    role: 統括・調整
    members: [CoordinatorAgent]
    authority:
      - タスク分解
      - Agent割り当て
      - リソース配分決定

  layer_3_specialist:
    role: 専門実行
    members: [CodeGenAgent, ReviewAgent, DeploymentAgent]
    authority:
      - 実装レベル決定
      - 品質判定
      - Staging環境デプロイ

3.2 エスカレーション経路

escalation_paths:
  case_1_technical_decision:
    trigger: "技術判断不能"
    path: Specialist → TechLead
    example: "TypeScriptコンパイルエラー(自動修正不能)"

  case_2_security_issue:
    trigger: "セキュリティリスク検出"
    path: Specialist → CISO
    example: "Critical脆弱性検出"

  case_3_p0_emergency:
    trigger: "本番障害"
    path: Specialist → PO + CTO
    example: "データ損失リスク"

エスカレーション実装:

export class BaseAgent {
  protected async escalate(reason: string, target: string): Promise<void> {
    // GitHub Issue作成
    const issue = await octokit.issues.create({
      title: `[Escalation] ${reason}`,
      body: `
## エスカレーション
Reason: ${reason}
Agent: ${this.name}
Target: ${target}
Timestamp: ${new Date().toISOString()}

## 詳細
${this.getEscalationDetails()}
      `,
      labels: ['🔥Sev.1-Critical', `👑担当-${target}`],
      assignees: [target]
    });

    // Slack通知
    await this.notifySlack({
      channel: '#escalations',
      text: `🚨 Escalation: ${reason}`,
      issue_url: issue.html_url
    });

    // memory_bank記録
    await this.updateMemoryBank('escalations', {
      reason,
      target,
      timestamp: new Date()
    });
  }
}

KPI

  • エスカレーション正答率: 100% (適切なTargetへのエスカレーション)
  • 平均解決時間: 2時間 (エスカレーション発生から解決まで)

原則4: 誤解・錯覚の排除

目的

曖昧さを排除し、すべての要件・完了条件を明示する。

実装

4.1 構造化プロトコル

codex_prompt_chain(YAML形式):

codex_prompt_chain:
  intent: "明確な目的を1文で記載"
  plan:
    - "ステップ1(5-7語)"
    - "ステップ2(5-7語)"
  implementation:
    - "変更ファイル: src/app.ts"
  verification:
    - "ESLint: 0 errors"

tool_invocations(JSON形式):

{
  "command": "npm run test",
  "workdir": "/path/to/repo",
  "timestamp": "2025-10-10T12:00:00Z",
  "status": "passed",
  "notes": "全テスト成功"
}

詳細はLog-Driven Developmentを参照。

4.2 完了条件の明示

completion_criteria:
  code_quality:
    - ESLint: 0 errors
    - TypeScript: 0 errors
    - Prettier: formatted

  testing:
    - Unit tests: passed
    - E2E tests: passed
    - Test coverage: ≥80%

  security:
    - Security scan: passed
    - Critical vulnerabilities: 0

  review:
    - Quality score: ≥80
    - Code review: approved

4.3 依存関係グラフ(DAG)

dependency_graph:
  visualization: "Mermaidダイアグラム"
  cycle_detection: "自動検出"
  blocker_display: "明示的表示"

  example:
    task-1:
      dependencies: []
      status: "completed"

    task-2:
      dependencies: [task-1]
      status: "in_progress"
      blocked_by: []

    task-3:
      dependencies: [task-1, task-2]
      status: "pending"
      blocked_by: [task-2]

詳細は並行実行アーキテクチャを参照。

KPI

  • 完了条件明示率: 100% (全タスクに完了条件明示)
  • 依存関係正確率: 100% (循環依存0件)

原則5: 感情的判断の排除

目的

主観的判断を排除し、データ駆動の客観的判断を実現する。

実装

5.1 数値基準

numeric_criteria:
  quality_judgment:
    - threshold: 80点
    - calculation: "100 - (eslint_errors * 20) - (ts_errors * 30) - (critical_vuln * 40)"
    - judgment: "score >= 80 → 合格"

  severity_evaluation:
    - Sev.1-Critical: "システム停止・データ損失"
    - Sev.2-High: "主要機能停止"
    - Sev.3-Medium: "一部機能影響"
    - Sev.4-Low: "軽微な不具合"
    - Sev.5-Idea: "改善提案"

  impact_evaluation:
    - Critical: "全ユーザー影響"
    - High: "主要機能影響"
    - Medium: "一部ユーザー影響"
    - Low: "限定的影響"

5.2 自動判定

Agent割り当て:

function assignAgent(task: Task): AgentType {
  // ルールベース判定(主観なし)
  if (task.type === 'feature' || task.type === 'bug') {
    return 'CodeGenAgent';
  } else if (task.type === 'review') {
    return 'ReviewAgent';
  } else if (task.type === 'deploy') {
    return 'DeploymentAgent';
  }

  throw new Error('Unknown task type');
}

PR承認:

async function autoApprove(pr: PullRequest): Promise<boolean> {
  // 品質スコアベース判定
  const qualityScore = await getQualityScore(pr);

  // テスト成功率
  const testSuccessRate = await getTestSuccessRate(pr);

  // 自動承認条件(主観なし)
  return (
    qualityScore >= 80 &&
    testSuccessRate >= 0.9 &&
    pr.critical_vulnerabilities === 0
  );
}

5.3 データ駆動レポート

{
  "execution_time_ms": 180000,
  "success_rate": 0.97,
  "error_rate": 0.03,
  "quality_score": 92,
  "metrics": {
    "eslint_errors": 0,
    "typescript_errors": 0,
    "test_coverage": 0.85,
    "critical_vulnerabilities": 0
  }
}

KPI

  • データ駆動判定実施率: 100% (全判断に数値基準使用)
  • 主観的判断発生率: 0% (人間の主観介入なし)

5原則の統合効果

相乗効果

原則1(責任明確化) + 原則3(階層明確化)
→ エスカレーション経路が明確になり、迅速な問題解決

原則2(結果重視) + 原則5(感情排除)
→ 客観的成果測定により、継続的改善が実現

原則4(誤解排除) + 原則5(感情排除)
→ 明確な基準と自動判定により、判断ブレがゼロ

実測効果

指標導入前導入後改善率
タスク完了率70%97%+38%
エスカレーション誤判定率15%0%-100%
平均実行時間10分3分-70%
品質スコア平均75点92点+23%

実装チェックリスト

Phase 1: 基盤構築

  • Agent階層構造定義
  • Label体系作成(65個)
  • CODEOWNERS設定
  • 品質スコア算出ロジック実装

Phase 2: 自動化

  • IssueAgent自動Label付与
  • ReviewAgent品質判定
  • CoordinatorAgentタスク分解
  • エスカレーション自動化

Phase 3: 監視・改善

  • KPI自動収集(6時間ごと)
  • ダッシュボード自動生成
  • レポート自動配信
  • 機械学習による最適化(今後)

トラブルシューティング

Issue 1: 担当者アサイン失敗

症状: Issueに担当者Label未付与

原因: CODEOWNERS設定漏れ

解決策:

# CODEOWNERSファイル確認
cat .github/CODEOWNERS

# Label同期
node scripts/sync-github-labels.cjs

Issue 2: 品質スコア計算異常

症状: 常に100点または0点

原因: ReviewAgentのロジックバグ

解決策:

# ReviewAgent単体テスト
npm run test -- agents/review-agent.test.ts

# デバッグログ有効化
DEBUG=agents:review npm run agents:review -- --code=src/

関連ドキュメント


次のステップ

すべてのアーキテクチャドキュメントを読み終えたら、以下に進むことを推奨します:

  1. Getting Started - 環境構築
  2. Agent運用マニュアル - 実践的な運用
  3. Integration Guide - 外部システム連携

参考リンク


最終更新: 2025-10-10 バージョン: 2.0.0 管理者: AI Operations Lead