public final class BindingTrace extends Object
dynamic-sql-fragment-provenance-design.md,
R3 / R4 step 3).
The dynamic-SQL per-edge publication proof (P3) needs the full binding
chain of every evidence reference, and its rule is fail-closed on
completeness: trace == null || !trace.complete ⇒ the reference is
unprovable. A missing trace is therefore always SAFE — it can only shrink
the published-edge set, never let an unproven edge through. This is why the
many direct setSourceTable sites in ScopeBuilder do not all need
instrumenting at once: uninstrumented paths simply yield no trace.
Captured today:
NameResolver.resolve) —
records the winning match's namespace, scope, resolve path and the
climb depth from the starting scope (correlated references);INSERTED/DELETED, trigger pseudo-tables, MERGE
target/SET/INSERT columns and MERGE USING values.Capture is off by default (TSQLResolverConfig.captureBindingTrace)
and observation-only: nothing in resolution reads a trace.
| Modifier and Type | Class and Description |
|---|---|
static class |
BindingTrace.BinderKind
What kind of binder resolved the reference.
|
| Modifier and Type | Field and Description |
|---|---|
BindingTrace.BinderKind |
binderKind |
boolean |
complete
TRUE iff the ENTIRE binding chain is known: an exact single-match scope
resolution with a recorded namespace, fully consumed name parts and a
known climb path — or a typed direct binding with a known target.
|
Object |
definitionNode
The AST node that DEFINES the binder: the
TTable of a table
namespace, the TCTE of a CTE namespace (header column lists
included), the TSelectSqlStatement of a derived table, or the
direct-binding target table. |
TTable |
directTarget
Direct-binding target table;
null for scope resolution. |
int |
matchCount
Number of matches the scope machinery reported (1 for a clean bind).
|
String |
matchedScope
Scope-type name where the winning match lives;
null when unknown. |
INamespace |
namespace
Winning namespace;
null for direct bindings or failed resolution. |
TTable |
observedSourceTable
The reference's
sourceTable AS OF capture time. |
TObjectName |
reference
The reference this trace describes (identity key in the registry).
|
String |
resolvePath
The winning match's resolve path (display form);
null when unknown. |
int |
scopeClimbDepth
Parent-scope hops from the starting scope to the matched scope; 0 for a
local bind, > 0 for correlated references, -1 when the matched scope
was not on the starting scope's parent chain (unknown — incomplete).
|
String |
startingScope
Scope-type name where resolution started;
null for direct bindings. |
ResolutionStatus |
status
Scope-machinery outcome;
null for direct bindings. |
| Modifier and Type | Method and Description |
|---|---|
static BindingTrace |
direct(TObjectName reference,
BindingTrace.BinderKind kind,
TTable target)
Typed direct-binding capture (ScopeBuilder clusters).
|
static BindingTrace |
scopeResolution(TObjectName reference,
ResolutionStatus status,
INamespace namespace,
Object definitionNode,
TTable observedSourceTable,
String startingScope,
String matchedScope,
String resolvePath,
int matchCount,
int scopeClimbDepth,
boolean fullyConsumed,
boolean exactMatch,
boolean fallbackUsed)
Scope-machinery capture (NameResolver choke point).
|
String |
toString() |
public final TObjectName reference
public final BindingTrace.BinderKind binderKind
public final ResolutionStatus status
null for direct bindings.public final INamespace namespace
null for direct bindings or failed resolution.public final TTable directTarget
null for scope resolution.public final Object definitionNode
TTable of a table
namespace, the TCTE of a CTE namespace (header column lists
included), the TSelectSqlStatement of a derived table, or the
direct-binding target table. This is what the publication proof checks
spans against; a trace without it cannot be complete.public final TTable observedSourceTable
sourceTable AS OF capture time. Two roles:
(a) staleness signal — post-resolution correction handlers (QUALIFY /
USING / subquery-alias / MERGE restores) may change or clear it, and the
registry invalidates the trace when the current value differs by
identity; (b) the FROM-reference wrapper node of the binding chain — for
CTE and derived-table binds this is the TTable carrying the
AS alias, whose span the definition node alone does not cover.
A complete scope trace requires it.public final String startingScope
null for direct bindings.public final String matchedScope
null when unknown.public final String resolvePath
null when unknown.public final int matchCount
public final int scopeClimbDepth
public final boolean complete
public static BindingTrace scopeResolution(TObjectName reference, ResolutionStatus status, INamespace namespace, Object definitionNode, TTable observedSourceTable, String startingScope, String matchedScope, String resolvePath, int matchCount, int scopeClimbDepth, boolean fullyConsumed, boolean exactMatch, boolean fallbackUsed)
public static BindingTrace direct(TObjectName reference, BindingTrace.BinderKind kind, TTable target)