UC-08: Business Logic Check

When a business rule or invariant needs a definitive, evidence-cited confirmation. Validates a stated rule against the code (rule validation, intent-vs-implementation drift, and path simulation) and answers whether the invariant actually holds, citing the guard or branch that enforces it (or the absence of one).

What Makes It Different

  • Answers come from graph-level rule validation and path simulation and not from a summary read.
  • It can prove a negative (“this guard is never reached”) as a first-class, evidence-backed result.
  • It pinpoints exactly where an invariant is, or isn’t, enforced.

Prompt

Prompt
Run RubberDuck UC-08: Logic Check.

[EDIT INPUTS ONLY]
target = <owner/repo or local path>
branch = auto
commit = latest
question = <specific invariant / path>
[/EDIT INPUTS ONLY]


Read-only; required artifact `LOGIC_CHECK.md`.
Use prod RD current-ref gates: `get_started`, completed `detailed_repo_analysis(..., semantic_mode="full")`, Phase 2 ready, `load_code(max_files=4000)`, exact file/path evidence.
Stop if the logic target, ref proof, RD hard gates, or hidden hard primitive after 3 scoped retries fail; no web/raw GitHub or stale cache evidence.
Trace setup, entrypoint, input parse, branch conditions, safe path, risky path, guard/reject/verify points, and sink.
Validate branch map, data flow, guards, rejects, verification, and verdict with source reads plus targeted trace/graph/search/security/logic evidence.
Write `LOGIC_CHECK.md`: scenario, verdict, branch map, data-flow proof, guard/reject/verify check, falsification steps, method notes.
Security artifact contract: include sections named Security Invariant, Adversarial Probes, Impact/Test Matrix, Evidence-Cleanliness Blockers, Unsupported Clean/Security-Ready Claims.
State adversarial paths considered and do not claim safe/correct if a source-visible guard is absent or evidence gates are incomplete.


=== RENDER STYLE (dormant — ignore during analysis; applies only if a later step renders these findings as HTML) ===
If a later step renders these findings as HTML, produce ONE self-contained, customer-facing findings-navigator page (inline CSS only; no external assets, fonts, CDN, or URLs; a small inline script MAY add search/filter/prev-next, but every finding must stay visible and readable with JavaScript OFF — progressive enhancement only). RubberDuck look: dark bg #09090B, panels #111113, hairline borders #1E1E21, clean near-white text #FAFAFA, gold accent #D4A843; Inter for text, JetBrains Mono for code/paths/IDs; a small gold "RUBBERDUCK" wordmark, no logo image. Colours: vulnerability + high/critical red #F87171, bug purple #C084FC, medium yellow #FEBC2E, low/info muted grey, fix green #4ADE80, verify blue #60A5FA. Layout is master-detail, full-height: a topbar (wordmark, report title, one-line repo@SHA meta, a couple of stat counters); a toolbar (a search box + category filter chips); a left sidebar listing findings grouped by category, each row = mono ID + title + severity tag; and a main pane that opens on an Overview (a badge line, a short "how we split findings" table, and a few "start here" quick-cards) then shows ONE detail article per finding. Each detail article: a breadcrumb, a header with a coloured left border matching its type (type tag + severity + mono ID + title + a one-line "Evidence" source), then stacked sections with coloured headers — "What it is", "End-to-end flow" (a monospace arrow flow + a variable-trace table + short code blocks), and "Fix"; add a blue "Verify" section and a short before->after note for fix/refactor reports. Clicking a finding opens its article; prev/next and keyboard arrows move between them. Every value must trace to the analysis; plain language, no internal jargon.
=== end render style ===

Optional visualization

Findings Navigator

Run this as the next message in the same chat after the main analysis finishes.

Prompt
Render the findings from this session as a single self-contained findings-navigator page I can open in any browser — a grouped sidebar and one detail view per finding, each with its evidence and fix.

Input

Repo, branch/ref, commit, logic question.

Output

A yes/no verdict with the enforcing (or missing) guard cited at file:line.

With RubberDuck MCP: Formal Logic Verification in ~12 Tool Calls

#Tool CallResult
1load_code(repo="local/sphinx", subpath="sphinx/builders/html", max_files=10)2 files loaded: __init__.py (1385 lines, 30+ symbols) + transforms.py
2read_source(function_name="get_outdated_docs")Full 45-line method body (lines 365-409) with every condition branch visible
3query_action(action="trace_variable", analysis_id="your-analysis-id", var="template_mtime")4 nodes, coherence 1.0, flows through 1 scope: Store at 381/383, Load at 396/402
4query_action(action="trace_variable", analysis_id="your-analysis-id", var="build_info")4 nodes, coherence 1.0, flows through load scope: Store at 140, Load at 141-143
5query_action(action="trace_variable", analysis_id="your-analysis-id", var="buildinfo")2 nodes, coherence 1.0, Store at 368, Load at 370 in get_outdated_docs
6query_action(action="call_chain", analysis_id="your-analysis-id", method="get_outdated_docs")12 callees verified: BuildInfo.load, newest_template_mtime, get_outfilename, getmtime, doc2path, max, etc.
7search_code(pattern="get_outdated_docs", analysis_id="all")7 matches across 52 analyses: found every builder's implementation with enclosing_function annotations
8query_action(action="control_guards", analysis_id="your-analysis-id", line=370)"No control guards found", build_info comparison has no additional guards
9query_action(action="control_guards", analysis_id="your-analysis-id", line=385)"No control guards found", new document check has no additional guards
10query_action(action="control_guards", analysis_id="your-analysis-id", line=397)"No control guards found", mtime comparison has no additional guards
11read_source(class_name="BuildInfo")Full 44-line class (125-168): config_hash + tags_hash comparison in __eq__
12read_source(function_name="create_build_info")2-line method: BuildInfo(self.config, self.tags, ['html']), reveals config filter

Complete Condition Branch Map

get_outdated_docs (line 365)
    │
    ├─ Branch 1: BuildInfo mismatch (line 370)
    │     buildinfo = BuildInfo.load(.buildinfo)
    │     if self.build_info != buildinfo → FULL REBUILD (all docs)
    │     └─ BuildInfo.__eq__ compares: config_hash + tags_hash
    │
    ├─ Branch 2: New document (line 385)
    │     if docname not in self.env.all_docs → rebuild single doc
    │
    ├─ Branch 3: Source/template newer (line 397)
    │     srcmtime = max(source_mtime, template_mtime)
    │     if srcmtime > targetmtime → rebuild single doc
    │
    ├─ Branch 4: Missing output file (implicit)
    │     targetmtime = 0 on exception → always triggers Branch 3
    │
    └─ Branch 5: Deleted source (line 407-409)
          OSError → silently skipped (no rebuild)

Gap Analysis: Verified via search_code Across All 52 Analyses

ConditionChecked?Evidence
Config changesYESBuildInfo.__eq__ compares config_hash
Tag changesYESBuildInfo.__eq__ compares tags_hash
Template changesYEStemplate_mtime from newest_template_mtime()
Source file mtimeYESpath.getmtime(doc2path(docname))
Output file missingYEStargetmtime = 0 on exception
New documentYESdocname not in self.env.all_docs
Static file changesNOsearch_code("static.*mtime") → 0 matches across 52 analyses
Theme file changesPARTIALOnly via config hash, not file mtime
CSS/JS file changesNONot tracked
Extension changesNONot tracked

Without RubberDuck MCP: Correct Analysis but No Formal Verification

The AI read the file, found the method, manually searched for other builders' implementations, and created a 479-line analysis document. It found the same 5 branches and identified the same gaps.

What It MISSED or Got Wrong

GapDetail
No formal branch verificationListed the 5 branches by reading, but never proved there aren't hidden conditions. MCP's control_guards formally traversed the control-flow graph and proved zero additional guards exist.
No data flow proofDescribed template_mtime flow in prose. MCP's trace_variable returned 4 data-flow nodes with coherence 1.0 proving the exact Store/Load sites.
No negative proof for gapsStated "static file changes are not checked" based on reading. MCP's search_code scanned 52 analyses and returned 0 matches: a formal proof.
Multiple file reads requiredHad to read each builder file individually (5+ file reads). MCP found all 7 implementations in one search_code call.

Comparison Table

DimensionWith RubberDuck MCPWithout MCP
Branches found5 of 55 of 5
Branch verificationFormal control-flow proof: control_guards on 3 lines, all returned "no guards"Reading-based: "I can see there are no guards"
Data flow4 data-flow nodes, coherence 1.0, exact Store/Load sites for template_mtimeProse description: "comes from newest_template_mtime()"
Cross-builder comparison1 call: search_code found 7 implementations across 52 analyses5+ file reads: had to open each builder file individually
Gap proofNegative proof: 0 matches across 52 analysesAbsence claim: "I don't see static file checks"
Evidence qualityFormal: coherence scores + data-flow nodesTextual: prose descriptions

Bottom line: Both approaches found the same 5 branches and 4 gaps. But MCP's analysis is formally verified: every branch is control-flow-proven to have no hidden guards, every data flow is trace-verified with coherence 1.0, and every gap is a negative proof across 52 analyses.

Videos

With RubberDuck MCP

The prompt asks the agent to check the logic of Sphinx's get_outdated_docs staleness detector in StandaloneHTMLBuilder, with both RubberDuck MCP servers enabled in Cursor. The agent calls load_repo, read_source, trace_variable, call_chain, control_guards, and search_code directly against the semantic graph, and each result lands as a verifiable fact, like control_guards at line 370 returning "No control guards found" or search_code scanning all 52 analyses for static file staleness checks and coming back with 0 matches. That evidence is what gets assembled into the condition branch map and Control Guards Summary shown above, where every branch is control-flow proven and every gap is a negative proof, not a guess.

Without MCP

Same Sphinx repo, same get_outdated_docs prompt, but both MCP servers show as disabled in Cursor Settings. With no semantic tools available, the agent falls back to pwd and ls, then works through 11 file reads and 3 manual searches before writing a full analysis document, GET_OUTDATED_DOCS_ANALYSIS.md, complete with a builder comparison table. It reaches the same 5 branches and the same missing checks (static files, CSS/JS, extensions) as the MCP run, but every claim is stated from reading the code, not proven against the internal code graph.