classCompletionWitness
final class CompletionWitness
Proves cheap feasible continuations before the complete search; a failed probe proves nothing. Every emitted witness actually walks the patterns, budget and output obligation without constructing SQL.
Methods§
public function __construct(
private CompletionCosts $costs,
private PatternProductions $productions,
private CompletionMemo $memo,
)Shares immutable production matches and unconstrained costs with the complete solver.
Parameters
$costs | CompletionCosts | |
$productions | PatternProductions | |
$memo | CompletionMemo |
public function complete(
list<Symbol> $symbols,
GenerationPlan<bool> $plan,
array<string, int> $occurrences,
bool $nonEmpty,
int $budget,
): ?intLimits this optional proof attempt to 256 expansions; null always delegates to the complete search.
Parameters
$symbols | list<Symbol> | |
$plan | GenerationPlan<bool> | |
$occurrences | array<string, int> | |
$nonEmpty | bool | |
$budget | int |
Returns
?intTest cases 3
Called from 1
Calls 15
- function-call
minline 41 - method-call CompletionCosts::hasTerminalOutput() line 42
- function-call
array_valuesline 43 - function-call
array_filterline 43 - method-call CompletionWitness::remember() line 45
- method-call CompletionState::key() line 47
- new CompletionState line 47
- method-call GenerationPlan::patternState() line 47
- method-call CompletionMemo::recall() line 49
- method-call PatternProductions::sourceRule() line 57
- function-call
array_sliceline 59 - method-call CompletionCosts::sequence() line 60
- method-call CompletionWitness::choices() line 63
- method-call GenerationPlan::patternAt() line 63
- static-call CompletionCosts::combine() line 64
public function remember(
list<array{string, int}> $path,
GenerationPlan<bool> $plan,
int $total,
int $budget,
): intStores only suffix costs from the actual successful walk, as affordable upper bounds.
Parameters
$path | list<array{string, int}> | |
$plan | GenerationPlan<bool> | |
$total | int | |
$budget | int |
Returns
intTest cases 1
Called from 2
- method-call SqlFaker\Generation\Derivation\Completion\CompletionWitness::complete() packages/sql-faker/src/Generation/Derivation/Completion/CompletionWitness.php:45
- method-call SqlFaker\Generation\Derivation\Completion\CompletionWitness::complete() packages/sql-faker/src/Generation/Derivation/Completion/CompletionWitness.php:51
Calls 1
- method-call CompletionMemo::remember() line 88
public function choices(
string $name,
?ProductionPattern $pattern,
): list<array{Production, array{int, int}}>Keeps the cheapest empty and emitting alternatives as proposals, never as constrained minimum proofs.
Parameters
$name | string | |
$pattern | ?ProductionPattern |
Returns
list<array{Production, array{int, int}}>Test cases 1
Called from 1
Calls 4
- function-call
serializeline 99 - method-call PatternProductions::matching() line 102
- method-call CompletionCosts::sequence() line 103
- function-call
array_valuesline 110
Private surface 4§
Implementation details, listed for orientation only.
private array<string, list<array{Production, array{int, int}}>> $choices = []private CompletionCosts $costsprivate PatternProductions $productionsprivate CompletionMemo $memoTest cases 28§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
CompletionWitnessTest::testChoicesCachesBothOutputPossibilitiesUnderEachDistinctPatterncallsCompletionWitnessTest::testCompleteBoundsTheOptionalProbeWithoutClaimingImpossibilitycallsCompletionWitnessTest::testCompleteWalksOccurrencePatternsAndPreservesPendingOutputcallsCompletionWitnessTest::testCompleteYieldsToTheSolverWhenAGreedyPathNeedsAnotherChoicecallsCompletionWitnessTest::testRememberCachesOnlyTheSuccessfulSuffixAndPreservesExactMinimumIndependencecalls
Other tests reaching this symbol 23
BytePlanCompilerTestcallsBytePlanEncoderTestcallsPlanBuilderTestcallsCompletionMemoTestcallsCompletionReductionTestcallsConstrainedCompletionTestcallsConstraintDependenciesTestcallsDerivationTestcallsDerivationTraceTestcallsTokenGeneratorTestcallsLexemeSequenceTestcallsCandidateResolverTestcallsSqlGeneratorTestcallsTerminalSequenceTestcallsGenerationContextTestcallsSqlGeneratorFactoryTestcallsMySqlProviderTestcallsGenerationContextTestcallsSqlGeneratorFactoryTestcallsPostgreSqlProviderTestcallsGenerationContextTestcallsSqlGeneratorFactoryTestcallsSqliteProviderTestcalls