PostgreSQL Review Workflow
Run the three declared PostgreSQL skills and both mandatory database agents against one source
snapshot. Reconcile logical model quality with real PostgreSQL operational behavior.
Declared inventory and dependencies
Runnable skills, exactly:
postgres-query-review
postgres-risk-check
postgres-schema-design
Mandatory agents:
postgres-dba
data-modeling-reviewer
Exclude the orchestrator ID postgres-review-workflow from recursive component execution.
Cost-aware native routing
Resolve portable profiles from the current runtime capability catalog at dispatch. Use query and
schema skill passes at frugal/low for bounded static changes; use migration risk, DBA, and data
modeling passes at standard/medium when operational or semantic judgment is required. Raise only
the affected pass to frontier/high for confirmed corruption, irreversible migration, authority,
or public-contract risk.
Every native handoff uses model_selection: explicit-native-override; spawn with fork_turns: none,
the exact resolved model, and exact reasoning_effort. Never inherit the primary model or reasoning
setting. Record requested/observed routes in the five-entry ledger and make mismatch INCOMPLETE.
Timeout, quota, authentication, and absent database access are not capability escalation signals.
Input contract
Accept the repository/diff scope plus available SQL, DDL/migrations, schema metadata, PostgreSQL
version, table/index sizes, row counts, query frequency, EXPLAIN (ANALYZE, BUFFERS) output,
deployment window, replication topology, and rollback constraints. State assumptions and preserve
the target revision. Never execute mutating SQL against a live database as part of review.
Workflow
1. Inventory and preflight
Resolve the three declared skills by canonical frontmatter name and both mandatory agents by
exact ID in the host runtime's effective catalogs after normal precedence rules. Use only discovery
roots active for this target; do not scan unrelated home or repository paths or infer identity from
directory names.
- If an effective catalog is unavailable, stop with
CATALOG_UNAVAILABLE.
- A missing mandatory dependency stops preflight with
MISSING_DEPENDENCY; a mandatory dependency
with ambiguous definitions after precedence stops with AMBIGUOUS_DEPENDENCY.
- Additional installed skills, including
postgres-code-authoring, are informational only.
They neither block preflight nor become review components. Exclude the orchestrator itself from
execution. A shared postgres- prefix does not make a skill a review dependency.
- The planned mandatory list must contain each of the three declared skills and two agents exactly
once, with no additional IDs. Missing, duplicate, or extra planned passes stop with
INVENTORY_MISMATCH.
Record declared IDs, resolved dependencies, additional discovered PostgreSQL IDs, and the planned
mandatory list separately.
Classify the scope as query, logical/physical schema, migration/backfill, or a combination. Every
mandatory dependency still runs; irrelevant areas return evidence-backed NOT_APPLICABLE.
2. Parallel specialist pass
Run at most four dependencies concurrently; start the fifth when a slot opens. Supply one frozen
scope to all runs. Require severity, confidence, SQL/artifact location, evidence, impact,
recommendation, rollback/deploy notes, and verification.
- Query review owns SQL correctness, plans, index usability, joins, sorting, pagination, and
before/after measurement.
- Risk check owns locks, rewrites, transaction size, concurrency, timeouts, rollback, and downtime.
- Schema design owns constraints, types, normalization, keys, relationships, and history modeling.
postgres-dba owns PostgreSQL operational feasibility and production safety.
data-modeling-reviewer owns semantic correctness, cardinality, business keys, temporal meaning,
redundancy, and conceptual/logical model quality.
3. Reconcile operational and modeling advice
Deduplicate only findings with the same database object or SQL location and root cause. Preserve
every contributor and the strongest supported severity.
For every recommendation that changes the model, record both views:
- Modeling effect: integrity, semantics, cardinality, normalization, redundancy, evolvability
- Operational effect: lock level, rewrite/scan, index build, WAL/replication, bloat, latency,
deployment sequence, rollback, and maintenance window
Do not let a clean target model justify unsafe one-step DDL. Do not let migration convenience erase
required integrity. When advice conflicts, produce a staged target-state migration that preserves
meaning while using safe PostgreSQL primitives; otherwise mark the conflict unresolved. Never
claim performance improvement without before/after plan or measurement evidence.
4. Verdict
Reconcile the mandatory run ledger against all five declared dependencies: require exactly one
terminal result per dependency. A missing, duplicate, or undeclared result makes coverage
INCOMPLETE; retain valid findings and identify the discrepancy.
INCOMPLETE: any mandatory dependency failed, timed out, or returned unusable output
BLOCK: supported CRITICAL safety, corruption, integrity, or irreversible rollout risk
CHANGES_REQUIRED: no CRITICAL finding and at least one supported HIGH finding
WARNING: only MEDIUM/LOW findings
APPROVE: all five dependencies completed and no supported finding remains
Unknown production size or absent plans lower confidence and may make deployability conditional;
they do not justify guessing.
Normalize supported severities to CRITICAL|HIGH|MEDIUM|LOW|NONE while retaining each contributor's
original label. When the verdict is INCOMPLETE but a completed pass found a supported CRITICAL,
keep INCOMPLETE as the terminal verdict and add blocking_finding_present: true; never hide the
known blocker behind the coverage failure.
Output contract
Return:
- scope, PostgreSQL version, revision, assumptions, and evidence availability
- declared IDs, resolved dependencies, informational extras, planned IDs, and five-entry run ledger
- aggregate verdict
- unified findings with exact objects/locations, contributors, evidence, and dissent
- reconciliation matrix: modeling target | operational risk | safe staged action | rollback |
verification
- corrected SQL/DDL proposals without applying them
- before/after EXPLAIN plan, lock/concurrency, integrity, and rollout verification checklist
- coverage gaps and next actions
Failure and partial-result semantics
- Unavailable or ambiguous mandatory dependencies and a mismatched mandatory execution plan stop
component execution. Additional installed skills do not invalidate the review inventory.
- Preserve successful outputs after a runtime failure, but return
INCOMPLETE; never approve four
out of five reviews.
- Treat unavailable database access as an explicit static-only limitation. Do not run destructive
probes to fill the gap.
- Mark results
STALE if the migration/schema revision changes during the run.
- Retry malformed output once with the contract restated; retain the failed dependency and gap if
it remains unusable.
1---2name: postgres-review-workflow3description: Run all PostgreSQL query, migration-risk, and schema-design skills plus operational DBA and data modeling reviewers, then reconcile their advice. Use for SQL, DDL, migrations, data models, performance incidents, or database changes that need one deployability-aware verdict.4---56# PostgreSQL Review Workflow78Run the three declared PostgreSQL skills and both mandatory database agents against one source9snapshot. Reconcile logical model quality with real PostgreSQL operational behavior.1011## Declared inventory and dependencies1213Runnable skills, exactly:1415- `postgres-query-review`16- `postgres-risk-check`17- `postgres-schema-design`1819Mandatory agents:2021- `postgres-dba`22- `data-modeling-reviewer`2324Exclude the orchestrator ID `postgres-review-workflow` from recursive component execution.2526## Cost-aware native routing2728Resolve portable profiles from the current runtime capability catalog at dispatch. Use query and29schema skill passes at `frugal/low` for bounded static changes; use migration risk, DBA, and data30modeling passes at `standard/medium` when operational or semantic judgment is required. Raise only31the affected pass to `frontier/high` for confirmed corruption, irreversible migration, authority,32or public-contract risk.3334Every native handoff uses `model_selection: explicit-native-override`; spawn with `fork_turns: none`,35the exact resolved `model`, and exact `reasoning_effort`. Never inherit the primary model or reasoning36setting. Record requested/observed routes in the five-entry ledger and make mismatch `INCOMPLETE`.37Timeout, quota, authentication, and absent database access are not capability escalation signals.3839## Input contract4041Accept the repository/diff scope plus available SQL, DDL/migrations, schema metadata, PostgreSQL42version, table/index sizes, row counts, query frequency, `EXPLAIN (ANALYZE, BUFFERS)` output,43deployment window, replication topology, and rollback constraints. State assumptions and preserve44the target revision. Never execute mutating SQL against a live database as part of review.4546## Workflow4748### 1. Inventory and preflight4950Resolve the three declared skills by canonical frontmatter `name` and both mandatory agents by51exact ID in the host runtime's effective catalogs after normal precedence rules. Use only discovery52roots active for this target; do not scan unrelated home or repository paths or infer identity from53directory names.5455- If an effective catalog is unavailable, stop with `CATALOG_UNAVAILABLE`.56- A missing mandatory dependency stops preflight with `MISSING_DEPENDENCY`; a mandatory dependency57 with ambiguous definitions after precedence stops with `AMBIGUOUS_DEPENDENCY`.58- Additional installed skills, including `postgres-code-authoring`, are informational only.59 They neither block preflight nor become review components. Exclude the orchestrator itself from60 execution. A shared `postgres-` prefix does not make a skill a review dependency.61- The planned mandatory list must contain each of the three declared skills and two agents exactly62 once, with no additional IDs. Missing, duplicate, or extra planned passes stop with63 `INVENTORY_MISMATCH`.6465Record declared IDs, resolved dependencies, additional discovered PostgreSQL IDs, and the planned66mandatory list separately.6768Classify the scope as query, logical/physical schema, migration/backfill, or a combination. Every69mandatory dependency still runs; irrelevant areas return evidence-backed `NOT_APPLICABLE`.7071### 2. Parallel specialist pass7273Run at most four dependencies concurrently; start the fifth when a slot opens. Supply one frozen74scope to all runs. Require severity, confidence, SQL/artifact location, evidence, impact,75recommendation, rollback/deploy notes, and verification.7677- Query review owns SQL correctness, plans, index usability, joins, sorting, pagination, and78 before/after measurement.79- Risk check owns locks, rewrites, transaction size, concurrency, timeouts, rollback, and downtime.80- Schema design owns constraints, types, normalization, keys, relationships, and history modeling.81- `postgres-dba` owns PostgreSQL operational feasibility and production safety.82- `data-modeling-reviewer` owns semantic correctness, cardinality, business keys, temporal meaning,83 redundancy, and conceptual/logical model quality.8485### 3. Reconcile operational and modeling advice8687Deduplicate only findings with the same database object or SQL location and root cause. Preserve88every contributor and the strongest supported severity.8990For every recommendation that changes the model, record both views:9192- **Modeling effect:** integrity, semantics, cardinality, normalization, redundancy, evolvability93- **Operational effect:** lock level, rewrite/scan, index build, WAL/replication, bloat, latency,94 deployment sequence, rollback, and maintenance window9596Do not let a clean target model justify unsafe one-step DDL. Do not let migration convenience erase97required integrity. When advice conflicts, produce a staged target-state migration that preserves98meaning while using safe PostgreSQL primitives; otherwise mark the conflict unresolved. Never99claim performance improvement without before/after plan or measurement evidence.100101### 4. Verdict102103Reconcile the mandatory run ledger against all five declared dependencies: require exactly one104terminal result per dependency. A missing, duplicate, or undeclared result makes coverage105`INCOMPLETE`; retain valid findings and identify the discrepancy.106107- `INCOMPLETE`: any mandatory dependency failed, timed out, or returned unusable output108- `BLOCK`: supported CRITICAL safety, corruption, integrity, or irreversible rollout risk109- `CHANGES_REQUIRED`: no CRITICAL finding and at least one supported HIGH finding110- `WARNING`: only MEDIUM/LOW findings111- `APPROVE`: all five dependencies completed and no supported finding remains112113Unknown production size or absent plans lower confidence and may make deployability conditional;114they do not justify guessing.115116Normalize supported severities to `CRITICAL|HIGH|MEDIUM|LOW|NONE` while retaining each contributor's117original label. When the verdict is `INCOMPLETE` but a completed pass found a supported CRITICAL,118keep `INCOMPLETE` as the terminal verdict and add `blocking_finding_present: true`; never hide the119known blocker behind the coverage failure.120121## Output contract122123Return:1241251. scope, PostgreSQL version, revision, assumptions, and evidence availability1262. declared IDs, resolved dependencies, informational extras, planned IDs, and five-entry run ledger1273. aggregate verdict1284. unified findings with exact objects/locations, contributors, evidence, and dissent1295. reconciliation matrix: modeling target | operational risk | safe staged action | rollback |130 verification1316. corrected SQL/DDL proposals without applying them1327. before/after EXPLAIN plan, lock/concurrency, integrity, and rollout verification checklist1338. coverage gaps and next actions134135## Failure and partial-result semantics136137- Unavailable or ambiguous mandatory dependencies and a mismatched mandatory execution plan stop138 component execution. Additional installed skills do not invalidate the review inventory.139- Preserve successful outputs after a runtime failure, but return `INCOMPLETE`; never approve four140 out of five reviews.141- Treat unavailable database access as an explicit static-only limitation. Do not run destructive142 probes to fill the gap.143- Mark results `STALE` if the migration/schema revision changes during the run.144- Retry malformed output once with the contract restated; retain the failed dependency and gap if145 it remains unusable.