docs: add DevOps deployment flow example#12
Conversation
Adds `examples/devops-flow.ts` demonstrating the MCP binding in a realistic CI/CD scenario: - deploy-bot agent scoped to staging with maxApprovableRisk 40 - production policy requiring majority review with escalateAbove 80 - log-deletion policy forcing peer review unconditionally - four MCP tools (read, staging deploy, production deploy, log delete) wrapped by TegataServer, each tagged with actionType and risk metadata Also adds `examples/` to the ESLint `ignores` list since the directory sits outside tsconfig's `include: ["src"]` and would otherwise fail the `projectService` check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds an ESLint flat-config override to disable type-aware linting for Changes
Sequence Diagram(s)sequenceDiagram
participant Dev as Developer/CLI
participant Tegata as Tegata Runtime
participant MCP as McpServer
participant Server as TegataServer
participant Tools as Tool Handlers
participant Reviewer as demoReviewer
Dev->>Tegata: setup() register agent, policies
Tegata->>MCP: create server instance
MCP->>Server: wrap McpServer in TegataServer
Server->>Tools: register tool handlers
Dev->>Server: submit proposal (client)
Server->>Tegata: evaluate proposal
Tegata->>Reviewer: request review decision
Reviewer-->>Tegata: approve/deny
Tegata->>Tools: invoke tool action (if approved)
Tools-->>Server: return CallToolResult
Server-->>Dev: respond with outcome
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a DevOps deployment flow example and updates the ESLint configuration to ignore the examples directory. The review feedback suggests maintaining static analysis for example code to ensure quality, removing redundant Promise wrapping in an async function, and fixing a potential cross-platform path comparison bug in the example's entry point.
| export default tseslint.config( | ||
| // Ignore build output and config files without tsconfig coverage | ||
| { ignores: ["dist/", "node_modules/", "vitest.config.ts"] }, | ||
| { ignores: ["dist/", "node_modules/", "examples/", "vitest.config.ts"] }, |
There was a problem hiding this comment.
There was a problem hiding this comment.
Good catch — fixed in fa4f6be. Moved examples/ out of the top-level ignores and added a scoped override that spreads tseslint.configs.disableTypeChecked and sets projectService: false / project: null, so style and safety rules still run even though the directory sits outside tsconfig.json's include: ["src"].
| return await Promise.resolve( | ||
| hasRollback | ||
| ? { | ||
| status: "approved", | ||
| decidedBy: "sre-lead", | ||
| reason: "rollback plan documented", | ||
| } | ||
| : { | ||
| status: "denied", | ||
| decidedBy: "sre-lead", | ||
| reason: "no rollback plan provided", | ||
| }, | ||
| ); |
There was a problem hiding this comment.
ここでの await Promise.resolve() の使用は冗長です。関数が既に async として宣言されているため、単にオブジェクトを返すだけで Promise としてラップされます。また、ハンドラー呼び出しを Promise.resolve().then() でラップするという一般的なルールは、同期/非同期のエラーを統一的に扱うための「呼び出し側」(この場合は src/core/runtime.ts 内の Tegata ランタイム)に向けたものであり、ハンドラーの実装自体で行う必要はありません。
return hasRollback
? {
status: "approved",
decidedBy: "sre-lead",
reason: "rollback plan documented",
}
: {
status: "denied",
decidedBy: "sre-lead",
reason: "no rollback plan provided",
};References
- 同期スローと非同期リジェクションの両方を一貫して処理するために、ハンドラーの呼び出しを
Promise.resolve().then().catch()チェーンでラップする。
There was a problem hiding this comment.
Fixed in fa4f6be. Agreed — the Promise.resolve(...) wrapper was a leftover from before the function was async. Removed; the function now returns the literal and the async declaration does the Promise wrapping.
| } | ||
|
|
||
| // Only run when executed directly (not when imported by tests/tools). | ||
| if (import.meta.url === `file://${process.argv[1] ?? ""}`) { |
There was a problem hiding this comment.
Fixed in fa4f6be. Replaced the string comparison with fileURLToPath(import.meta.url) === process.argv[1] via node:url, which normalizes to the native filesystem path on both POSIX and Windows.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f846b348bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| capabilities: ["ci:*:read", "ci:staging:*"], | ||
| maxApprovableRisk: 40, |
There was a problem hiding this comment.
Configure deploy-bot to allow the review-path example
The delete-logs flow is described as a review-tier example, but with this agent registration it is unreachable: deploy-bot has only ci:*:read/ci:staging:* and maxApprovableRisk: 40, while the tool uses ci:logs:delete with riskScore: 70. In Tegata.propose() (capability and agent-risk checks), either condition escalates before policy review handlers run, so this path will always be escalated rather than reviewed.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Good catch — fixed in fa4f6be. The better fix is to make the review tier actually reachable, since demonstrating it is the whole point of the tool. Added ci:logs:delete to deploy-bot's capabilities and lowered the delete-logs tool to riskScore: 35 (within maxApprovableRisk: 40). Capability + risk checks now pass and the proposal reaches the policy layer, which forces review.
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
eslint.config.mjs (1)
6-6: Keepexamples/linted with a dedicated override instead of fully ignoring it.Line 6 currently disables all lint checks for example code. That makes the sample likely to drift from repo standards. Prefer a scoped override (disable only type-aware rules for examples) so style/safety rules still run.
♻️ Suggested config adjustment
- { ignores: ["dist/", "node_modules/", "examples/", "vitest.config.ts"] }, + { ignores: ["dist/", "node_modules/", "vitest.config.ts"] }, + + // Examples: linted, but not type-aware (outside main tsconfig include) + { + files: ["examples/**/*.ts"], + ...tseslint.configs.disableTypeChecked, + languageOptions: { + parserOptions: { projectService: false }, + }, + },As per coding guidelines
**/*.{ts,tsx}: “Use TypeScript strict mode with noanytypes” and “Enforceimport type…”, which should remain enforced for TypeScript files, including examples.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@eslint.config.mjs` at line 6, Remove "examples/" from the top-level ignores array and instead add an overrides entry that targets "examples/**/*.{ts,tsx}" so example files remain linted; in that override disable type-aware rules by clearing parserOptions.project (set to undefined/null) or explicitly turning off the type-info rules so style and non-type rules still run while skipping rules that require type-checking. Update the file's ignores array (remove "examples/") and add an overrides object with a pattern for examples and the parserOptions/rules change to scope the exception.examples/devops-flow.ts (1)
60-63: Avoidprocess.exit(1)during module initialization.These exits run before the direct-exec guard (Line 310), so an import can terminate the caller process if setup ever fails. Move setup/error-exit behind
main()execution path (or return an error from setup and let the direct-run block decide whether to exit).Also applies to: 117-120, 130-133
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@examples/devops-flow.ts` around lines 60 - 63, The code currently calls process.exit(1) during top-level setup when registerResult.ok is false (and in other top-level checks around the registerResult logic), which can terminate the importer; change the pattern so setup returns an error instead of exiting: move the register call and its failure handling into the main execution path (e.g., inside main() or a setupAsync() function), or have registerAgent()/setup functions throw or return a Result that main() inspects and then call process.exit only from the direct-exec guard; update the failure handling for the other top-level checks (the blocks at the other noted spots) to follow the same pattern and remove direct process.exit calls from module initialization.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@examples/devops-flow.ts`:
- Line 18: Update the documentation entries so that the "delete-logs" action is
marked as "escalated" (not "review tier"): change the listing at the top (line
18) and the detailed example block (lines ~264–267) to state that "delete-logs"
is escalated due to the deploy-bot lacking the ci:logs:delete capability (it
only has ci:*:read and ci:staging:*) and because the action's riskScore (70)
exceeds deploy-bot's maxApprovableRisk (40); reference the runtime checks in
src/core/runtime.ts (the capability check around the proposer capability logic
and the risk check) when updating the explanatory text so it explicitly cites
"capability gap + riskScore > maxApprovableRisk" as the reason for escalation.
---
Nitpick comments:
In `@eslint.config.mjs`:
- Line 6: Remove "examples/" from the top-level ignores array and instead add an
overrides entry that targets "examples/**/*.{ts,tsx}" so example files remain
linted; in that override disable type-aware rules by clearing
parserOptions.project (set to undefined/null) or explicitly turning off the
type-info rules so style and non-type rules still run while skipping rules that
require type-checking. Update the file's ignores array (remove "examples/") and
add an overrides object with a pattern for examples and the parserOptions/rules
change to scope the exception.
In `@examples/devops-flow.ts`:
- Around line 60-63: The code currently calls process.exit(1) during top-level
setup when registerResult.ok is false (and in other top-level checks around the
registerResult logic), which can terminate the importer; change the pattern so
setup returns an error instead of exiting: move the register call and its
failure handling into the main execution path (e.g., inside main() or a
setupAsync() function), or have registerAgent()/setup functions throw or return
a Result that main() inspects and then call process.exit only from the
direct-exec guard; update the failure handling for the other top-level checks
(the blocks at the other noted spots) to follow the same pattern and remove
direct process.exit calls from module initialization.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c41b08a2-f53a-40b3-99ba-f0727f02e082
📒 Files selected for processing (2)
eslint.config.mjsexamples/devops-flow.ts
- eslint.config.mjs: re-enable linting for examples/ via a scoped
override that disables type-aware rules only (style/safety rules
still run), per CodeRabbit + Gemini review.
- examples/devops-flow.ts:
- Move setup out of module scope into a setup() Result function
called from main(); no more process.exit() side-effects on
module import.
- Drop redundant `await Promise.resolve(...)` in demoReviewer —
async already wraps the return.
- Replace `import.meta.url === file://${process.argv[1]}` guard
with `fileURLToPath()` for cross-platform path comparison.
- Fix delete-logs review-tier demonstration: give deploy-bot the
`ci:logs:delete` capability and lower riskScore to 35 so the
proposal actually reaches the policy layer instead of escalating
on agent enforcement.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review fixes pushed (fa4f6be)Addressed all 5 inline findings. Summary:
Verified with |
|
@gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a DevOps deployment flow example and updates the ESLint configuration to accommodate the new examples directory. Feedback includes a recommendation to enable type-aware linting for examples via a dedicated tsconfig to prevent API misuse, and a suggestion to improve the robustness of the entry point check in the example script by resolving process.argv[1] to an absolute path.
| files: ["examples/**/*.ts"], | ||
| ...tseslint.configs.disableTypeChecked, | ||
| languageOptions: { | ||
| parserOptions: { projectService: false, project: null }, | ||
| }, | ||
| }, |
| // `fileURLToPath` normalizes `import.meta.url` to a native filesystem | ||
| // path, which matches `process.argv[1]` on both POSIX and Windows. | ||
| const entryPoint = process.argv[1]; | ||
| if (entryPoint !== undefined && fileURLToPath(import.meta.url) === entryPoint) { |
There was a problem hiding this comment.
Summary
examples/devops-flow.tsを追加。TegataServerを実利用する CI/CD シナリオ(deploy-bot + 4 tools + 2 policies)のエンドツーエンド例main()がサマリ出力eslint.config.mjsのignoresにexamples/を追加(tsconfig のinclude: [\"src\"]外なのでprojectServicecheck が失敗するため)Why
v0.1 の MCP binding がマージされたあと、README の snippet 以外に「動く例」が無かった。ADR-005 が説明する composition 設計を具体的に触れる形で示すのが目的です。
Notes for reviewers
import.meta.urlguard 付き)examples/を tsconfig に含めるか別途tsconfig.examples.jsonを切るかは要議論。今回は ignore で一旦通したexamples/をランタイムテストする場合はignores撤去 + 専用 tsconfig の方向でTest plan
pnpm run typecheckpasspnpm run lintpass(prettier + eslint)pnpm tsx examples/devops-flow.tsで設定サマリが出力されることを手元で確認(レビュー時に実行推奨)🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Documentation