Killer Use Case: PR Review Gate (CI)
If you want Cognitive to spread, you need one workflow that is obviously better than ad-hoc prompting. This is that workflow: turn AI code review into a verifiable merge-gate contract, and use it to block risky PRs in CI.
You get:
- A stable v2.2 envelope (
ok/meta/data|error) every run. meta.riskandmeta.confidencefor routing.- Post-validation and policy diagnostics (
meta.policy.*) when providers differ.
5-Minute Local Demo
export GEMINI_API_KEY=sk-xxx
cat <<'EOF' | npx cogn@2.2.16 pipe --module pr-risk-gate --pretty --profile standard --provider gemini --model gemini-3-pro-preview
diff --git a/auth.py b/auth.py
@@
-def login(user, password):
- query = "SELECT * FROM users WHERE name = ? AND password = ?"
- return db.execute(query, (user, password)).fetchone()
+def login(user, password):
+ query = f"SELECT * FROM users WHERE name = '{user}' AND password = '{password}'"
+ return db.execute(query).fetchone()
EOF
ChatGPT / OpenAI variant:
export OPENAI_API_KEY=sk-xxx
cat <<'EOF' | npx cogn@2.2.16 pipe --module pr-risk-gate --pretty --profile standard --provider openai --model gpt-5.2
diff --git a/auth.py b/auth.py
@@
-def login(user, password):
- query = "SELECT * FROM users WHERE name = ? AND password = ?"
- return db.execute(query, (user, password)).fetchone()
+def login(user, password):
+ query = f"SELECT * FROM users WHERE name = '{user}' AND password = '{password}'"
+ return db.execute(query).fetchone()
EOF
What to look for:
meta.riskis set (none|low|medium|high) and should behighheremeta.explainis short (max 280 chars)data.decisionis canonical (for examplereject_until_security_fix)data.findings[]uses stable labels such assql_injectionandparameterized_queriesdata.rationalestays long-form for audit
CI Gate: Block High Risk, Allow Low Risk
In a PR workflow, you typically:
- Compute a diff (
git diff base...head) - Run
pr-risk-gateon the diff - Fail the job if
meta.risk === "high"ordata.blocking === true
We now ship a copy-paste template:
- Module:
cognitive/modules/pr-risk-gate - Workflow + script:
templates/use-cases/pr-review-gate
Recommended Policy Defaults
- Use
--profile standardfor day-to-day. - Use
--profile certifiedfor high-stakes repos (stricter gates). - Leave
--structured autoon (best cross-provider stability).
Example:
npx cogn@2.2.16 pipe --module pr-risk-gate --pretty --profile standard --structured auto
Why This Works (And “Just Prompting” Doesn’t)
- CI needs a machine-readable contract. Free-form text is brittle.
- Providers have different schema/JSON mode behavior. Cognitive normalizes to one contract and records decisions.
meta.risk+ canonicaldata.decisiongives you a routing primitive: allow, require review, block.- The contract is benchmarked against raw prompting.
raw-textfails;coreandstandardstay stable.
See also: