Factory inspection models are usually trained only on images of good parts. One common fix is to fake defects and train the model to tell them apart from normal images. This works well for scratches and stains. It works poorly for logical defects, where every part looks fine but the assembly breaks a rule: a missing screw, two labels where there should be one, a cable routed to the wrong side. A realistic logical defect is a short program of edits to the scene, such as "remove this component, shift that one, duplicate a third." Most such programs are either harmless or obviously broken. The informative ones are rule violations the current detector still scores as normal, and they are rare. Finding them is a search problem, so we propose to solve it with the tool built for sparse, delayed payoffs over discrete action sequences: tree search guided by a learned value function, in the style of AlphaGo-like planners.
Concretely, we describe each normal image as a scene graph, meaning a list of components with their counts, positions and pairwise relations. We fit a density model of what normal scene graphs look like. We then run Monte Carlo Tree Search (MCTS), a planner that grows a tree of partial action sequences and spends more simulations on promising branches. The search runs over sequences of graph edits. A leaf is rewarded when three things hold: the edited graph certifiably leaves the normal support, its rendered image looks realistic, and the current detector misses it. A small graph neural network learns to predict this reward from partial edit sequences, so the expensive rendering step and detector call happen only at the most promising leaves. The detector is retrained on what the search finds, the search adapts to the new detector, and the loop repeats. The claim is that, at a fixed budget of renders and detector calls, planned edit sequences find hard and valid logical anomalies far more often than random or greedy edits, and that this translates into better logical-anomaly detection on MVTec LOCO AD.
Where this sits
The edit vocabulary and renderer come from prior work. LogicAL extracts edge maps, applies Remove, Replace and Merge operations, and re-renders them with edge-to-image GANs. It reports 69.7 pixel AU-sPRO on MVTec LOCO, but it picks its operations at random and never checks whether a given edit challenges the detector. ComGEN builds logical defects by deleting component tokens from prompts and by sampling from low-density regions of a diffusion model, reaching 91.2% AUROC on LOCO. Its authors list multi-component functional relations as unsolved, and nothing in its pipeline searches over combinations of components. Both papers motivate our work: they show that structured edits are the right raw material, and that the choice of which edits to make is left to chance.
The search side is borrowed. AutoSynth is the closest prior use of MCTS for synthetic data. It searches over prompt-and-code workflows for text datasets and scores them with an LLM judge. Our search instead runs over edits to individual samples, and the reward comes from the detector's own blind spots plus a density-based validity certificate, not from a judge's opinion of quality. Our design choices are constrained by CircuitBuilder. There, model-free Soft Actor-Critic (SAC) beat PPO with MCTS on easy two-variable targets (about 57.8% vs about 35%), but collapsed on three-variable targets (about 10.7% vs about 27.3%). We read this as a warning that search pays off only when the combinatorial space is large, so our experiments vary edit depth explicitly instead of assuming search helps. ExPoSe shows that sharing visit-count statistics across a tree helps sparse-reward search (97.09% vs 83.53% for PUCT on Hamiltonian cycles). It also documents the cost of a simulator in the loop, which is why we search over cheap scene graphs and render only at the leaves.
Deep Anomaly Detection via Active Anomaly Search uses SAC to find anomalies inside an existing unlabeled pool. It generates nothing and does no lookahead. Adversarial Outlier Exposure pushes generated outliers toward the boundary with gradient steps on an energy model (CIFAR-100 AUROC 93.7% vs 84.4% for standard outlier exposure). Those continuous steps cannot express "delete one of two identical parts," and nothing stops a perturbed sample from drifting back into normal data. Our validity certificate is aimed at exactly that drift.
The strongest constraint on our design comes from the shortcut trap documented by SPot-the-Difference: detectors trained on pasted defects learn to spot blending seams, not defects. A search that maximizes "fools the detector" is especially exposed to this. It could learn to exploit renderer artifacts, or the detector could learn to recognize anything that went through the renderer. We address this structurally. Every normal scene graph is also passed unedited through the same renderer and added to training as a normal example. Renderer artifacts are then present on both sides of the boundary and stop carrying information.
Core Claim
Let $g$ be a scene graph and $R(g)$ its rendered image. Let $p_N$ be the density of normal scene graphs, $s_D(\cdot)\in[0,1]$ the current detector's anomaly score, and $q(\cdot)\in[0,1]$ a realism score from a discriminator trained on round-tripped normal renders. The reward at a terminal edit sequence is
$$r(g) = \mathbb{1}\left[-\log p_N(g) > \tau\right]\cdot q(R(g))\cdot\left(1 - s_D(R(g))\right) - \lambda\,|e|,$$
Here $\tau$ is set at a high quantile of $-\log p_N$ over held-out normal graphs, so the first factor certifies a violation. The term $|e|$ is the number of edits and $\lambda$ a small penalty that favors minimal violations.
The reward is sparse and delayed. Many single edits leave the graph inside normal support, for example moving a component within its usual range. Many pairs of edits that are each harmless combine into a violation, for example swapping two components so that counts are preserved but a relational rule breaks. These two-step combined violations are the defects that random edits rarely hit and greedy edits cannot see, because the first step scores zero. That is the specific condition under which lookahead with a learned value should beat sampling.
Research Program
We build three components. The first extracts scene graphs. Each LOCO category gets class-agnostic segments, clustered across normal images into component types. The graph records counts, centroids, relative offsets and type adjacency. $p_N$ is a simple factorized density (counts, pairwise offset Gaussians, co-occurrence), so the validity certificate stays interpretable. The second is the edit space and renderer. Graph edits (delete, duplicate, swap type, translate, re-route) are mapped onto LogicAL-style edge-map operations and rendered with its edge-to-image GAN, with round-tripped normals added as described above. The third is the planner. We use PUCT-style MCTS over edit sequences of depth up to five. A graph network supplies both a prior over edits and a value estimate, and it is trained on the rewards of leaves that were actually rendered. Training alternates: search produces a batch of hard anomalies, the detector (a DRÆM-style reconstruction-plus-segmentation network) is retrained on them, and the value network is refit to the moving detector.
We will also analyze where the gains come from. We measure the hit rate, defined as the fraction of rendered leaves that are both certified and missed by the detector. We track it as a function of edit depth, and we break down LOCO test anomalies by type (count, arrangement, missing part) to see which ones improve. As a secondary test of generality, the same planner can run over causal-graph edits for multivariate sensor data, using the causal discovery and link-breaking augmentor of CAROTS. There the reported reference is 0.622 AUROC on WADI. This is a stretch goal and not part of the main claim.
Baselines
The naive reference point is the same detector trained with DRÆM's Perlin-noise and texture anomalies only (DRÆM, 98.0 image AUROC on MVTec AD). It shows how much any logical synthesis adds. We found no reported result on Lacuna for DRÆM's absolute score on LOCO; GLCF only reports beating it by 24.9% in sPRO. We will therefore run it ourselves.
The strongest existing methods are LogicAL (69.7 pixel AU-sPRO on LOCO) and ComGEN (91.2% image AUROC on LOCO). We will rerun both with our detector backbone and training schedule, and also quote their reported numbers. Beating them means exceeding 91.2% image AUROC and 69.7 AU-sPRO on LOCO's logical split, without losing structural-defect performance.
The baseline that actually tests the claim is matched-budget random search. It samples edit sequences uniformly from the same edit space and renderer, applies the same reward, and keeps the best leaves. It gets exactly the same number of renders and detector calls, and the same round-trip normals. We add a greedy variant (best single edit, repeated) and a model-free PPO policy over the same edits with the same budget.
Two ablations isolate our ingredients. MCTS with random rollouts in place of the value network tests whether the learned value earns its keep. The full system without round-trip normals tests the shortcut defense. MCTS wins only if its hit rate is clearly higher at matched budget, and if this yields better LOCO logical AUROC, averaged over three seeds with non-overlapping spread.
Why not just…?
Why not just sample many random edit sequences and keep the ones the detector misses? This is the real threat, and the matched-budget random baseline exists to settle it. If valid hard violations are dense among random sequences, best-of-N filtering will match MCTS and the search is unnecessary. We expect search to win only at edit depth three and above, where single steps carry no reward signal. CircuitBuilder's depth-dependent reversal makes this prediction plausible but not certain. If random filtering ties at all depths, we will drop the planner and report the validity-certified, artifact-controlled adversarial generation as the contribution on its own.
Why not just train a model-free RL policy to emit edits? In CircuitBuilder, SAC was better on small spaces and collapsed on larger ones. Edit spaces over multi-component scenes grow the same way. The PPO baseline at equal budget, run at each edit depth, measures this directly instead of assuming it.
Why not just push samples toward the boundary with gradients, as AOE does? Count and arrangement violations are discrete. A gradient step in pixel or latent space cannot delete exactly one of two screws, and it offers no check that the result left normal support. We still include a latent-space AOE-style variant on the renderer's input codes to show this empirically, and we measure what fraction of its outputs pass the density certificate.
Why not just prompt a diffusion model, as ComGEN does? Prompt deletion handles presence and absence well. It is weakest exactly on relational and count-preserving violations, a limitation ComGEN acknowledges. RODEO also reports about one hour per 10,000 low-resolution samples on an RTX 3090 (RODEO), which makes iterating against a changing detector expensive. The per-type breakdown will show whether our gains concentrate on relational defects. If they do not, ComGEN's approach suffices.
Proposed Experiments
The main experiment trains each generator–detector pair on LOCO normal images only and reports image AUROC and AU-sPRO on the logical and structural splits separately. The same pipeline runs on MVTec AD to confirm that structural performance does not drop.
The decisive check is the curve of hit rate and downstream logical AUROC against the budget of renders and detector calls, for edit depths one through five. MCTS must dominate random and greedy search at depth three and above. Otherwise the core claim is false.
The second check targets shortcuts. We train a probe to separate round-tripped normals from raw normals. If the full system's gains vanish when round-trip normals are removed, or the probe succeeds above chance after training with them, the detector was learning the renderer rather than the defects.
The third check is a manual audit. People will review 200 search outputs and record the fraction that are genuine rule violations rather than renderings that look normal. This verifies that the density certificate prevents drift back into normal data in practice.
References
- LogicAL: Towards logical anomaly synthesis for unsupervised anomaly localization
- Component-Aware Unsupervised Logical Anomaly Generation for Industrial Anomaly Detection
- AutoSynth: Automated Workflow Optimization for High-Quality Synthetic Dataset Generation via Monte Carlo Tree Search
- CircuitBuilder: From Polynomials to Circuits via Reinforcement Learning
- ExPoSe: Combining State-Based Exploration with Gradient-Based Online Search
- Deep Anomaly Detection via Active Anomaly Search
- Out-of-Distribution Detection with Adversarial Outlier Exposure
- SPot-the-Difference Self-supervised Pre-training for Anomaly Detection and Segmentation
- Causality-Aware Contrastive Learning for Robust Multivariate Time-Series Anomaly Detection
- DRÆM - A discriminatively trained reconstruction embedding for surface anomaly detection
- Learning Global-Local Correspondence with Semantic Bottleneck for Logical Anomaly Detection
- RODEO: Robust Outlier Detection via Exposing Adaptive Out-of-Distribution Samples