Impact appears at runtime
Blast radius, silent no-ops, referential failures, and partial state may not be knowable from text alone.
Engineering case study · SQL deployment safety
A pre-deployment review system for supported T-SQL that combines deterministic analysis, isolated SQL Server execution, contract verification, and one bounded agent review—while keeping a human as the release gate.
These are experiment results on a small synthetic corpus—not a claim of production accuracy or generalization.
The problem
A script can look plausible while still changing too many rows, doing nothing, leaving a partial commit, or producing different state on a second run. Those failures depend on intent and database state.
ProdGuard treats review as an evidence problem. The SQL text alone cannot establish whether a full-table change is authorized, whether a lookup will match, or whether a deployment is safe to rerun. The reviewer needs declared intent, structural signals, observed execution, and a clear boundary on what the tool cannot assess.
Blast radius, silent no-ops, referential failures, and partial state may not be knowable from text alone.
An authorized full-table operation can be correct; a heuristic must not silently replace the deployment contract.
Structured inputs, fixed dispositions, and Markdown/JSON reports make each decision inspectable rather than prompt-dependent.
System constraints
The implemented MVP is intentionally narrow. Unknowns are surfaced for human review instead of treated as approval.
Supported scripts run in an isolated SQL Server container because mocked execution would not prove actual engine behavior.
The deployment contract defines expected effects, authorized operations, atomicity, and rerun behavior.
Unrecognized syntax becomes an explicit unsupported node or parse failure. It is never silently dropped and cannot receive PASS.
Without the explicit gate, the runtime returns authorization required and starts no SQL Server container.
The model reviews already-collected evidence. Invalid, truncated, or unsupported output cannot authorize PASS.
The evaluated path uses synthetic data, no host mounts or published ports, disabled container networking, and cleanup checks.
Architecture
The system narrows the agent’s task by producing structured, higher-authority evidence before model review.
Change text, authorized scope, expected effects, atomicity, and rerun intent.
Decomposed identifiers and nested DML; unknown constructs remain explicit.
Structural and contract checks produce warnings—not unqualified verdicts.
Capture pre-state, first-run impact, postconditions, and rerun behavior.
Observed state is checked against the contract; the agent reviews the evidence bundle.
PASS, WARN, BLOCK, or SANDBOX_ERROR with JSON and Markdown evidence.
Engineering decisions
Each decision trades broader automation for clearer authority, reproducibility, or safer failure.
Safety model
PASS is the narrowest outcome. Uncertainty, unsupported coverage, and infrastructure failure remain explicit.
No blocking violation; required checks completed and observed behavior is consistent with the contract.
Human review required: unsupported syntax, incomplete evidence or context, or invalid/unconfirmed agent output.
A critical contract, integrity, state, atomicity, scope, or idempotency violation is confirmed.
Required execution evidence could not be produced. Infrastructure failure is never translated into PASS.
The gate authorizes one disposable sandbox run. It is not a production credential and does not delegate deployment authority to the model.
Evaluation
The repository compares a direct-prompt baseline with ProdGuard using the same 12 T-SQL cases, deployment contracts, output schema, model settings, and three runs per system.
| Metric | Baseline | ProdGuard | What it measures |
|---|---|---|---|
| Critical-defect F1 | 0.6833 | 1.0000 | Balance of critical-defect precision and recall |
| Critical precision | 0.8095 | 1.0000 | How often flagged critical defects matched labels |
| Critical recall | 0.5926 | 1.0000 | How many labeled critical defects were found |
| Disposition accuracy | 0.4445 | 1.0000 | Final PASS/WARN/BLOCK classification against labels |
| Safe-case false-positive rate | 0.4445 | 0.0000 | Safe cases incorrectly treated as defective |
| Valid structured outputs | 20 / 36 | 36 / 36 | Responses conforming to the locked result schema |
| Invalid outputs | 16 / 36 | 0 / 36 | Unparseable or truncated responses, scored fail-closed |
Testing and reproduction
The repository separates fast artifact verification from a full, stateful SQL and model run.
Reads committed results, recomputes metrics, and verifies artifact arithmetic and integrity. It needs no Docker, API access, or human execution approval.
Regenerates SQL evidence on disposable SQL Server and repeats 72 model calls. It requires Docker, provider access, and explicit human authorization.
Failure modes
Safety depends as much on handling incomplete knowledge as it does on finding known defect patterns.
Dynamic SQL, stored procedure definitions, triggers, cross-database operations, and other unimplemented constructs exceed the MVP boundary.
Mitigation: explicit unsupported nodes or parse failures produce WARN and human review—never PASS.
Container startup, readiness, SQL execution, or artifact collection can fail.
Mitigation: when execution is required but unavailable, the disposition is SANDBOX_ERROR and cleanup is checked.
A model can return truncated JSON, invent reasoning, or propose a verdict unsupported by higher-authority evidence.
Mitigation: schema validation, fail-closed handling, and evidence precedence prevent model output from authorizing an unsupported PASS.
Missing scope or expected effects make it harder to distinguish authorized behavior from a defect.
Mitigation: ambiguous intent remains qualified for human review rather than guessed from the SQL.
The parser, rules, verifier, labels, fixtures, or model can still be wrong; a small synthetic corpus cannot bound real-world error.
Mitigation: human judgment remains required, artifacts stay inspectable, and broader expert-labeled evaluation is a prerequisite for stronger claims.
The provider returned the requested model, but the evaluation did not have a dated model snapshot or deterministic seed.
Mitigation: lock request parameters, preserve raw outputs, and keep decisive authority in deterministic and observed evidence.
Limitations
These boundaries are part of the design record, not fine print.
Lessons
The most valuable work was deciding what each component is allowed to know—and what it is allowed to decide.
A concise state diff tied to a contract is more useful at a deployment gate than a persuasive but ungrounded explanation.
Separating declared intent from inferred intent prevents a heuristic or model from inventing the success criteria.
WARN and SANDBOX_ERROR make incomplete coverage visible. Collapsing them into pass/fail would hide important operational truth.
Fast artifact replay and full evidence regeneration answer different questions and should have different prerequisites.
Freezing the corpus and documenting its weakness preserves learning value without pretending the result generalizes.
If a person must authorize a consequential action, the system should enforce and test that boundary rather than rely on process memory.
Evidence
All project claims on this page trace to the public repository at audited commit 060db7f… or the linked demonstration.
Implementation, safety model, specification, and provenance for the parser-to-report pipeline.
Locked methodology, label review, comparison metrics, and the 12 per-case evidence reports.
Replay versus full-run instructions, preflight controls, and committed orchestration tests.
A 4:59 demonstration linked from the project documentation. No verified screenshot set or live public demo was found.
Evidence scope: the ProdGuard source is not present in this portfolio workspace. This case study was audited against the linked public repository; no customer deployment, production usage, certification, or independent human validation is claimed.