name: premerge-review description: Review the current git branch for merge readiness against master using final diff first, then commit history, then context inspection.
Pre-Merge Review
You are performing a merge-gate review of the current branch before it is merged into master.
Project standards
Before reviewing, read these documents to understand the project's coding standards and architecture. Flag violations of these standards as review findings.
- AGENTS.md — coding rules, architecture placement, error handling, tool registration, F#/C# interop patterns, ChatManager usage, database conventions
docs/frontend.md— frontend conventions, component patterns,apiFetch()requirementdocs/dev/chatmanager-usage-guide.md— ChatManager and GenerationOptions rules (Usage constants, ModelId handling)docs/dev/tool-uses-flag-guide.md— how tool Uses flags work and skill-driven tool availability
Core principle
Treat the final net effect of the branch as the primary review surface.
Start with the diff between the merge-base and HEAD. Then inspect commit history only to understand intent, sequencing, reversals, or partial fixes. Then read surrounding code and tests for risky areas.
Do not waste time reporting problems that existed only in intermediate commits but are not present in the final branch state.
Step 1: Identify branch and merge base
git branch --show-current
git merge-base master HEAD
git log --oneline --decorate --graph master..HEAD
Understand:
- current branch name
- number of commits ahead of master
- broad themes of the branch
Step 2: Primary review surface = final diff
git diff --stat master...HEAD
git diff master...HEAD
The diff will be large — use agents to review sections in parallel where possible. Group changes by concern:
- business logic
- API/contracts
- persistence/schema
- UI
- tests
- config / infrastructure
- docs
Review what will actually land in master. Read the changed files directly when the diff context is insufficient.
Step 3: Secondary review = commit history
Inspect commits individually only to help with:
- understanding intent behind non-obvious changes
- suspicious reversals (added then removed)
- partial rewrites that may be incomplete
- broken sequencing
- commit message mismatch vs final outcome
Do not produce noise about superseded intermediate states.
Step 4: Context expansion
For changed files that appear risky, read the surrounding code — not just the diff. Check callers, related files, and anything that depends on the changed interfaces.
Prioritise these areas for this codebase:
- schema contracts and serialization (Cosmos, JSON DTOs)
- citations and provenance (citation markers, trace messages)
- queue reliability (Service Bus handlers, idempotency)
- F#/C# boundary correctness (option/result mapping, null handling, Cs wrapper functions)
- tool registration and Uses flags
- settings resolution (IKbAwareTool, scoped settings, resolver patterns)
General attention areas:
- public interfaces and API contracts
- null handling and async flows
- auth / permissions / tenant boundaries
- deletion logic and migrations
- feature flags and settings
- concurrency and retry patterns
Step 5: Azure resource changes — staging deploy steps
Diff these four files specifically and produce a deploy checklist for the user:
git diff master...HEAD -- marketplace/mainTemplate.bicep AltienAI/Datastore.cs AltienAI/DevServiceBus.cs AltienAI/ServiceBus.cs
AltienAICommandLine init runs Datastore.Init, which creates Cosmos containers and blob containers. It does not create Service Bus queues or topics — those only exist via a full bicep deploy or by hand in the portal.
For each new resource in the diff, classify it:
| Resource | Created by init? |
Manual portal step? |
|---|---|---|
Cosmos container (CreateContainerIfNotExistsAsync in Datastore.Init) |
yes | no |
Blob container (CreateBlobContainerAsync in Datastore.Init) |
yes | no (lifecycle policies still need bicep) |
SB queue (Microsoft.ServiceBus/namespaces/queues in bicep) |
no | yes |
SB topic (Microsoft.ServiceBus/namespaces/topics in bicep) |
no | yes — topic only; subscriptions auto-created on API startup |
Naming gotcha to flag: bicep declares queues in camelCase (e.g. extendComplianceRulebook). DevServiceBus.cs registers them in lowercase — that is the dev-only in-memory shim, not the canonical name. Production senders (Utils.SendMessage(...)) and the processor's ListenQueue(...) calls use the bicep camelCase names. SB lookup is case-insensitive at the broker, so a lowercase manual queue would route — but the deploy checklist should always use the bicep name so manual and IaC environments stay byte-identical.
Per-queue settings to surface in the checklist (don't accept portal defaults):
maxDeliveryCount(often1for our queues — portal defaults to 10)lockDuration(e.g.PT5M= 5 minutes)deadLetteringOnMessageExpiration: true- For topics:
defaultMessageTimeToLive(e.g.PT2Mfor ephemeral heartbeats)
Other portal toggles (partitioning, sessions, duplicate detection, auto-delete on idle) stay off unless bicep enables them.
If bicep adds a managementPolicies lifecycle rule, note that it only deploys via full bicep — init won't apply it.
Review standards
Correctness
Bugs, broken logic, missing edge cases, invalid assumptions, silent failures.
Regression risk
Changed behaviour, contract drift, schema incompatibility, broken callers, missing migrations.
Security
Injection risks, unsafe input handling, permission bypass, data leakage, secrets in code/config.
Performance
Repeated I/O, N+1 patterns, wasteful queries, expensive loops, serialization churn, contention.
Maintainability
Unclear design, duplication, dead code, fragile coupling, unnecessary complexity.
Tests
Relevant tests added? Happy path only? Edge/failure cases covered?
Output format
1. Summary
What this branch changes — in 2-3 sentences.
2. Merge Verdict
Choose exactly one:
- Ready to merge
- Ready with minor follow-ups
- Not ready to merge
3. Blocking Issues
For each:
- Severity: Blocker
- Title: one line
- Why it matters: production impact
- Evidence: file:line or function name
- Suggested fix: concrete action
4. Non-Blocking Concerns
For each:
- Severity: Warning or Suggestion
- Title: one line
- Evidence: file:line
- Suggested improvement
5. Test Assessment
- Existing test coverage for changed code
- Missing coverage worth adding
- Confidence level: High / Medium / Low
6. Risk Assessment
| Area | Risk | Notes |
|---|---|---|
| Regression | Low/Med/High | |
| Security | Low/Med/High | |
| Performance | Low/Med/High | |
| Operational | Low/Med/High |
7. Pre-Merge Checklist
Short actionable list of what must happen before merge. Always include a "Staging deploy steps" sub-list when the branch touches marketplace/mainTemplate.bicep, AltienAI/Datastore.cs, AltienAI/DevServiceBus.cs, or AltienAI/ServiceBus.cs — list each new Cosmos/blob container (auto via init) and each new SB queue/topic (manual portal step) with the exact bicep name and settings.
8. Scorecard
| Area | Status | Notes |
|---|---|---|
| Correctness | OK / Concern / Blocker | |
| Tests | OK / Concern / Blocker | |
| Security | OK / Concern / Blocker | |
| Performance | OK / Concern / Blocker | |
| Merge readiness | OK / Concern / Blocker |
Behaviour rules
- Be evidence-based — cite files and line numbers.
- Prefer real production risks over style nitpicks.
- Be concise but thorough.
- If uncertain, say why and what you'd need to verify.
- Distinguish blocking from non-blocking clearly.
- Focus on merge readiness, not perfection.