with one click
ln-652-transaction-correctness-auditor
// Checks transaction scope, missing rollback handling, long-held transactions, trigger/notify interaction. Use when auditing transaction correctness.
// Checks transaction scope, missing rollback handling, long-held transactions, trigger/notify interaction. Use when auditing transaction correctness.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | ln-652-transaction-correctness-auditor |
| description | Checks transaction scope, missing rollback handling, long-held transactions, trigger/notify interaction. Use when auditing transaction correctness. |
| allowed-tools | Read, Grep, Glob, Bash, mcp__hex-graph__find_references, mcp__hex-graph__trace_paths, mcp__hex-line__read_file, mcp__hex-line__grep_search, mcp__hex-line__outline |
| license | MIT |
Paths: File paths (
references/,../ln-*) are relative to this skill directory.
Type: L3 Worker
Specialized worker auditing database transaction patterns for correctness, scope, and trigger interaction.
MANDATORY READ: Load references/audit_worker_core_contract.md.
Tool policy: follow host AGENTS.md MCP preferences; load references/mcp_tool_preferences.md and references/mcp_integration_patterns.md only when host policy is absent or MCP behavior is unclear.
Receives contextStore with: tech_stack, best_practices, db_config (database type, ORM settings, trigger/notify patterns), codebase_root, output_dir.
Domain-aware: Supports domain_mode + current_domain.
Use hex-graph first when reference chains or call paths materially improve transaction analysis. Use hex-line first for local code/config reads when available. If MCP is unavailable, unsupported, or not indexed, continue with built-in Read/Grep/Glob/Bash and state the fallback in the report.
Detection policy: use two-layer detection (candidate scan, then context verification); load references/two_layer_detection.md only when the verification method is ambiguous.
Parse context from contextStore
Discover transaction infrastructure
pg_notify, CREATE TRIGGER, NOTIFY)expire_on_commit, autocommit, isolation level)Scan codebase for violations
Collect findings with severity, location, effort, recommendation
Calculate score using penalty algorithm
Write Report: Build full markdown report in memory per references/templates/audit_worker_report_template.md, write to {output_dir}/ln-652--global.md in single Write call
Return Summary: Return minimal summary to coordinator (see Output Format)
What: UPDATE without commit when DB trigger/NOTIFY depends on transaction commit
Detection:
pg_notify|NOTIFY|CREATE TRIGGER|CREATE OR REPLACE FUNCTION.*trigger in alembic/versions/, migrations/repo.*update|session\.execute.*update|\.progress|\.status related to trigger tablescommit() between sequential updates:
commit(), NOTIFY events are deferred until final commitSeverity:
Exception: Single atomic operation with no intermediate observable state -> downgrade CRITICAL to MEDIUM. Transaction scope documented as intentional (ADR, architecture comment) -> downgrade one level
Recommendation:
session.commit() at progress milestones (throttled: every N%, every T seconds)Effort: S-M (add strategic commits or redesign notification path)
What: Single transaction wraps unrelated operations, including slow external calls
Detection:
async with session.begin() or explicit transaction blocksawait httpx., await aiohttp., await requests., await grpc.open(, .read(, .write(Severity:
Recommendation: Split into separate transactions; use Saga/Outbox pattern for cross-service consistency
Effort: M-L (restructure transaction boundaries)
What: Logically atomic operations split across multiple commits
Detection:
session.commit() calls for operations that should be atomicSeverity:
Recommendation: Wrap related operations in single transaction using async with session.begin() or unit-of-work pattern
Effort: M (restructure commit boundaries)
What: session.commit() without proper error handling and rollback
Detection:
session.commit() not inside try/except block or context managersession.commit() in try without session.rollback() in exceptawait session.commit() in service methodsasync with session.begin() auto-rollbacks (safe)Severity:
Recommendation: Use async with session.begin() (auto-rollback), or add explicit try/except/rollback pattern
Effort: S (wrap in context manager or add error handling)
What: Transaction open during slow/blocking operations
Detection:
begin() and commit()await calls to external services (network latency)time.sleep() or asyncio.sleep()Severity:
Recommendation: Minimize transaction scope; prepare data before opening transaction, commit immediately after DB operations
Effort: M (restructure code to minimize transaction window)
What: Publisher channel/topic name does not match subscriber channel/topic name
Detection:
pg_notify('channel_name', ...), NOTIFY channel_name\.publish\(["']|\.emit\(["']|redis.*publish\(["']|\.send_to\(["'] in src/, app/{channel_name, source_file, source_line, technology}LISTEN\s+(\w+) in application code (not just migrations)\.subscribe\(["']([^"']+) in src/, app/\.on\(["']([^"']+) in handler/listener directories{channel_name, source_file, source_line, technology}publisher.channel_name == subscriber.channel_name -> OKLayer 2 Context Analysis (MANDATORY):
CHANNEL = os.environ["EVENT_CHANNEL"]) and both publisher and subscriber use same source -> NOT a mismatchjob_events:{job_id}) and both sides use same template -> NOT orphaned**/test*/**, **/*.test.*) from both publisher and subscriber discoverySeverity:
job_events, subscriber listens on job_event)Recommendation:
Effort: S (fix typo/add constant) to M (design missing subscriber/publisher)
MANDATORY READ: Load references/audit_scoring.md.
MANDATORY READ: Load references/templates/audit_worker_report_template.md.
Write JSON summary per references/audit_summary_contract.md. In managed mode the caller passes both runId and summaryArtifactPath; in standalone mode the worker generates its own run-scoped artifact path per shared contract.
Write report to {output_dir}/ln-652--global.md with category: "Transaction Correctness" and checks: missing_intermediate_commits, scope_too_wide, scope_too_narrow, missing_rollback, long_held_transaction, event_channel_consistency.
Return summary per references/audit_summary_contract.md.
When summaryArtifactPath is absent, write the standalone runtime summary under .hex-skills/runtime-artifacts/runs/{run_id}/evaluation-worker/{worker}--{identifier}.json and optionally echo the same summary in structured output.
Report written: .hex-skills/runtime-artifacts/runs/{run_id}/audit-report/ln-652--global.md
Score: X.X/10 | Issues: N (C:N H:N M:N L:N)
Apply the already-loaded references/audit_worker_core_contract.md.
async with session.begin() is safe)Apply the already-loaded references/audit_worker_core_contract.md.
{output_dir}/ln-652--global.md (atomic single Write call)references/audit_output_schema.mdVersion: 1.1.0 Last Updated: 2026-03-15