GitHub as OS
概要: GitHubの15のコア機能をOSコンポーネントとして活用し、完全自律型AI開発環境を実現するアーキテクチャです。Issues(プロセス)、Projects V2(データベース)、Webhooks(イベントバス)、Actions(スケジューラ)等を統合したオペレーティングシステムとしてGitHubを運用します。
対象読者: アーキテクト / システム管理者 所要時間: 20分 前提知識: システム全体像
GitHub as OS アーキテクチャ
OS階層モデル
┌─────────────────────────────────────────────────────────┐
│ GitHub as OS │
├─────────────────────────────────────────────────────────┤
│ │
│ User Space: │
│ ├─ Issues (Processes) ✅ │
│ ├─ PRs (Patches) ✅ │
│ ├─ Discussions (Message Queue) ✅ │
│ └─ Gists (Shared Memory) ✅ │
│ │
│ Kernel Space: │
│ ├─ Actions (Scheduler) ✅ │
│ ├─ Webhooks (Event Bus) ✅ │
│ ├─ Projects V2 (Database) ✅ │
│ └─ API (System Calls) ✅ │
│ │
│ Hardware Layer: │
│ ├─ Runners (CPU) ✅ │
│ ├─ Packages (Storage) ✅ │
│ ├─ Pages (Display) ✅ │
│ └─ Secrets (HSM) ✅ │
│ │
│ Security: │
│ ├─ Branch Protection (Firewall) ✅ │
│ ├─ CodeQL (Antivirus) ✅ │
│ ├─ Dependabot (Auto-update) ✅ │
│ └─ Secret Scanning (DLP) ✅ │
│ │
└─────────────────────────────────────────────────────────┘
User Space(ユーザー空間)
1. Issues - プロセス管理
役割: タスク/バグ/機能をプロセスとして管理
issue_as_process:
pid: Issue #270
state: open/closed
priority: Sev.1-5
assignee: worker-id
labels: [✨feature, ⭐Sev.2-High]
dependencies: [#240, #250]
lifecycle:
- created: プロセス起動
- labeled: リソース割り当て
- assigned: CPU割り当て
- in_progress: 実行中
- completed: 終了
- closed: プロセス終了
統合例:
// Issue作成 = プロセス起動
const issue = await octokit.issues.create({
title: "Fix Firebase Auth bug",
body: `
## 概要
Firebase Auth認証エラー修正
## 依存関係
- Requires: #240 (Firebase SDK更新)
- Blocks: #280 (E2Eテスト)
`,
labels: ['🐛bug', '⭐Sev.2-High', '👤担当-開発者'],
assignees: ['alice']
});
2. Pull Requests - パッチ管理
役割: コード変更をパッチとして管理
pr_as_patch:
patch_id: PR #309
state: draft/ready/merged
base: main
head: fix/270-auth-bug
reviewers: [tech-lead]
checks:
- lint: passed
- test: passed
- security: passed
lifecycle:
- draft: パッチ作成
- ready_for_review: レビュー待ち
- approved: 承認済み
- merged: 適用完了
3. Discussions - メッセージキュー
役割: Agent間通信・アイデア収集
discussion_as_mq:
category: Ideas
purpose: "Agent間非同期通信"
features:
- async_communication: 非同期メッセージング
- topic_based: トピック別分類
- idea_to_issue: アイデア→Issue変換
統合例:
// Agent間メッセージ送信
await octokit.discussions.create({
repositoryId: 'repo-id',
categoryId: 'agent-messages',
title: 'Task #270 completed',
body: `
## 完了報告
Task: Firebase Auth修正
Status: ✅ Completed
Quality Score: 95/100
次のステップ: PR #309のレビュー
`
});
Kernel Space(カーネル空間)
4. GitHub Actions - スケジューラ
役割: タスクスケジューリング・自動実行
actions_as_scheduler:
cron_jobs:
- name: "並行実行モニタリング"
schedule: "*/5 * * * *" # 5分ごと
command: "npm run worker:health-check"
- name: "Lock自動クリーンアップ"
schedule: "0 * * * *" # 1時間ごと
command: "npm run lock:cleanup"
event_triggers:
- on: issues.opened
run: IssueAgent分析
- on: pull_request.opened
run: ReviewAgent品質チェック
- on: push.main
run: DeploymentAgent本番デプロイ
ワークフロー例:
# .github/workflows/autonomous-agent.yml
name: Autonomous Agent Execution
on:
issues:
types: [opened, labeled]
jobs:
analyze-issue:
runs-on: ubuntu-latest
steps:
- name: IssueAgent実行
run: npm run agents:issue -- --number=${{ github.event.issue.number }}
- name: CoordinatorAgent実行
run: npm run agents:coordinator -- --issue=${{ github.event.issue.number }}
5. Webhooks - イベントバス
役割: イベント駆動アーキテクチャ
webhook_as_eventbus:
events:
- issues.*
- pull_request.*
- push
- release
- deployment
security:
- hmac_sha256: 署名検証
- replay_protection: リプレイ攻撃防止
delivery:
- retry_strategy: 指数バックオフ (1s → 8s)
- timeout: 10秒
イベントルーター実装:
// scripts/webhook-router.ts
export class WebhookRouter {
async route(event: WebhookEvent): Promise<void> {
// HMAC署名検証
if (!this.verifySignature(event)) {
throw new Error('Invalid signature');
}
// イベント種別でルーティング
switch (event.type) {
case 'issues.opened':
await this.handleIssueOpened(event);
break;
case 'pull_request.opened':
await this.handlePROpened(event);
break;
case 'push':
await this.handlePush(event);
break;
}
}
private verifySignature(event: WebhookEvent): boolean {
const signature = crypto
.createHmac('sha256', process.env.WEBHOOK_SECRET!)
.update(event.payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(`sha256=${signature}`),
Buffer.from(event.headers['x-hub-signature-256'])
);
}
}
6. Projects V2 - データベース
役割: 構造化データ永続化
projects_v2_as_database:
tables:
- name: "Parallel Work Dashboard"
fields:
- status: Single Select
- priority: Number
- assignee: User
- estimated_duration: Number
- quality_score: Number
- agent_type: Single Select
views:
- by_worker: グループ化(Assignee)
- by_status: グループ化(Status)
- by_priority: ソート(Priority)
- timeline: ガントチャート風
api:
- graphql: データ読み書き
- mutations: データ更新
- queries: データ検索
GraphQL統合:
// packages/github-projects/client.ts
export class ProjectsClient {
async updateTaskStatus(taskId: string, status: string): Promise<void> {
const mutation = `
mutation UpdateItem($projectId: ID!, $itemId: ID!, $fieldId: ID!, $value: String!) {
updateProjectV2ItemFieldValue(
input: {
projectId: $projectId
itemId: $itemId
fieldId: $fieldId
value: { singleSelectOptionId: $value }
}
) {
projectV2Item {
id
}
}
}
`;
await this.graphql(mutation, {
projectId: process.env.PROJECT_ID,
itemId: taskId,
fieldId: 'status-field-id',
value: status
});
}
}
Hardware Layer(ハードウェア層)
7. GitHub Runners - CPU
役割: コンピューティングリソース
runners_as_cpu:
types:
- ubuntu-latest: Linux環境
- macos-latest: macOS環境
- windows-latest: Windows環境
- self-hosted: 専用サーバー
specs:
- cpu_cores: 2-4
- memory: 7-14GB
- storage: 14-90GB
scaling:
- concurrent_jobs: 最大20並行
- timeout: 最大6時間
8. GitHub Packages - ストレージ
役割: パッケージ配布・コンテナレジストリ
packages_as_storage:
types:
- npm: @miyabi/agent-sdk
- docker: ghcr.io/user/miyabi-agent
- maven: com.miyabi:agent-core
- nuget: Miyabi.Agent.Core
features:
- versioning: セマンティックバージョニング
- access_control: public/private
- retention: 自動削除ポリシー
パッケージ公開:
# NPM公開
npm publish --registry=https://npm.pkg.github.com
# Docker公開
docker build -t ghcr.io/user/miyabi-agent:latest .
docker push ghcr.io/user/miyabi-agent:latest
9. GitHub Pages - ディスプレイ
役割: ダッシュボード・ドキュメント公開
pages_as_display:
url: https://user.github.io/repo/
features:
- static_site: 静的サイトホスティング
- custom_domain: カスタムドメイン対応
- https: 自動SSL証明書
content:
- dashboard: リアルタイムKPIダッシュボード
- docs: API仕様書
- reports: 並行実行レポート
ダッシュボード例:
<!-- docs/index.html -->
<!DOCTYPE html>
<html>
<head>
<title>Autonomous Operations Dashboard</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
</head>
<body>
<h1>Parallel Work Dashboard</h1>
<div class="metrics">
<div class="metric">
<h2>AI Task成功率</h2>
<p class="value">97%</p>
</div>
<div class="metric">
<h2>平均実行時間</h2>
<p class="value">3分</p>
</div>
</div>
<canvas id="successRateChart"></canvas>
<script>
// 5分ごとに自動更新
setInterval(updateDashboard, 300000);
</script>
</body>
</html>
Security Layer(セキュリティ層)
10. Branch Protection - ファイアウォール
役割: mainブランチ保護
branch_protection_as_firewall:
rules:
- require_pull_request: true
- require_reviews: 1
- require_status_checks:
- lint
- test
- security-scan
- enforce_admins: true
- restrict_push: []
11. CodeQL - アンチウイルス
役割: 静的解析・脆弱性検出
codeql_as_antivirus:
languages:
- typescript
- javascript
- python
checks:
- sql_injection
- xss
- path_traversal
- hardcoded_secrets
schedule: "0 6 * * 1" # 毎週月曜6時
12. Dependabot - 自動更新
役割: 依存パッケージ自動更新
dependabot_as_autoupdate:
package_ecosystems:
- npm:
directory: "/"
schedule: "weekly"
open_pull_requests_limit: 10
- github-actions:
directory: "/"
schedule: "weekly"
security:
- auto_merge_patch: true
- auto_merge_minor: false
13. Secret Scanning - DLP
役割: 機密情報漏洩防止
secret_scanning_as_dlp:
patterns:
- github_token: github_pat_*
- aws_key: AKIA*
- api_key: sk-*
- private_key: "-----BEGIN PRIVATE KEY-----"
actions:
- alert: セキュリティアラート
- revoke: 自動無効化(GitHub Token)
- notify: 管理者通知
統合実装例
フルサイクル自動化
# Issue作成 → 自動実行 → デプロイ
workflow:
1_issue_created:
event: issues.opened
webhook: ✅ EventBus
action: IssueAgent分析
storage: Projects V2更新
2_task_decomposition:
runner: ubuntu-latest ✅ CPU
action: CoordinatorAgent実行
output: タスクDAG
3_parallel_execution:
runners: [ubuntu-1, ubuntu-2] ✅ 並行CPU
actions: [CodeGenAgent, ReviewAgent]
locks: .task-locks/ ✅ 排他制御
4_pr_creation:
action: PRAgent実行
webhook: pull_request.opened ✅ EventBus
notification: Discussions投稿 ✅ MessageQueue
5_deployment:
runner: ubuntu-latest ✅ CPU
action: DeploymentAgent実行
target: GitHub Pages ✅ Display
package: GitHub Packages ✅ Storage
パフォーマンスメトリクス
実績データ
| メトリック | 目標 | 実績 | ステータス |
|---|---|---|---|
| 実装時間 | 36h | 26h | ✅ 28%短縮 |
| 並行効率 | 50% | 72% | ✅ 超過達成 |
| テストカバレッジ | 80% | 92% | ✅ 超過達成 |
| Dashboard読込時間 | <2s | ~1.5s | ✅ |
| Webhook応答時間 | <3s | ~1.2s | ✅ |
| セキュリティ脆弱性 | 0 | 0 | ✅ |
使用例
1. Issue作成 → 自動実行
gh issue create \
--title "Add user authentication" \
--body "Implement OAuth2 flow"
# Webhook triggers:
# 1. IssueAgent analyzes
# 2. CoordinatorAgent decomposes
# 3. CodeGenAgent implements
# 4. PR automatically created
2. ダッシュボード監視
URL: https://user.github.io/repo/
リアルタイムメトリクス:
- Agent成功率: 97%
- 平均実行時間: 3分
- コスト追跡: $0.05/issue
- 品質スコア: 92/100
3. 環境デプロイ
# GitHub UI: Actions → Deploy to Environment
# 環境選択: production
# 承認: 2人のレビューア必須
他プロジェクトへの適用
セットアップ手順
# 1. Miyabi CLIインストール
npx miyabi init my-project
# 2. コアファイルコピー
cp -r .github/workflows/ my-project/
cp -r packages/github-projects/ my-project/
cp -r scripts/webhook-*.ts my-project/
# 3. Secrets設定
gh secret set GITHUB_TOKEN
gh secret set ANTHROPIC_API_KEY
# 4. GitHub機能有効化
# - Discussions
# - Pages
# - Secret Scanning
# - Dependabot
関連ドキュメント
- システム全体像 - 全体構成
- Agent階層システム - Agent構造
- 並行実行アーキテクチャ - 並行実行
- 組織設計原則 - 5原則実装
次のステップ
- Log-Driven Development - LDDプロトコルを学ぶ
- Agent運用マニュアル - 実際の運用方法を理解する
最終更新: 2025-10-10 バージョン: 2.0.0 管理者: AI Operations Lead