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 |
Test cases 5
CompletionWitnessTest::testChoicesCachesBothOutputPossibilitiesUnderEachDistinctPatterncoversCompletionWitnessTest::testCompleteBoundsTheOptionalProbeWithoutClaimingImpossibilitycoversCompletionWitnessTest::testCompleteWalksOccurrencePatternsAndPreservesPendingOutputcoversCompletionWitnessTest::testCompleteYieldsToTheSolverWhenAGreedyPathNeedsAnotherChoicecoversCompletionWitnessTest::testRememberCachesOnlyTheSuccessfulSuffixAndPreservesExactMinimumIndependencecovers
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
CompletionWitnessTest::testCompleteBoundsTheOptionalProbeWithoutClaimingImpossibilitycovers and callsCompletionWitnessTest::testCompleteWalksOccurrencePatternsAndPreservesPendingOutputcovers and callsCompletionWitnessTest::testCompleteYieldsToTheSolverWhenAGreedyPathNeedsAnotherChoicecovers and calls
Called from 1
Calls 14
- 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
- function-call
array_sliceline 58 - method-call CompletionCosts::sequence() line 59
- method-call CompletionWitness::choices() line 62
- method-call GenerationPlan::patternAt() line 62
- static-call CompletionCosts::combine() line 63
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 4
CompletionWitnessTest::testCompleteBoundsTheOptionalProbeWithoutClaimingImpossibilitycoversCompletionWitnessTest::testCompleteWalksOccurrencePatternsAndPreservesPendingOutputcoversCompletionWitnessTest::testCompleteYieldsToTheSolverWhenAGreedyPathNeedsAnotherChoicecoversCompletionWitnessTest::testRememberCachesOnlyTheSuccessfulSuffixAndPreservesExactMinimumIndependencecovers and calls
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 87
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 4
CompletionWitnessTest::testChoicesCachesBothOutputPossibilitiesUnderEachDistinctPatterncovers and callsCompletionWitnessTest::testCompleteBoundsTheOptionalProbeWithoutClaimingImpossibilitycoversCompletionWitnessTest::testCompleteWalksOccurrencePatternsAndPreservesPendingOutputcoversCompletionWitnessTest::testCompleteYieldsToTheSolverWhenAGreedyPathNeedsAnotherChoicecovers
Called from 1
Calls 4
- function-call
serializeline 98 - method-call PatternProductions::matching() line 101
- method-call CompletionCosts::sequence() line 102
- function-call
array_valuesline 109
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 25§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
CompletionWitnessTest::testChoicesCachesBothOutputPossibilitiesUnderEachDistinctPatterncovers and callsCompletionWitnessTest::testCompleteBoundsTheOptionalProbeWithoutClaimingImpossibilitycovers and callsCompletionWitnessTest::testCompleteWalksOccurrencePatternsAndPreservesPendingOutputcovers and callsCompletionWitnessTest::testCompleteYieldsToTheSolverWhenAGreedyPathNeedsAnotherChoicecovers and callsCompletionWitnessTest::testRememberCachesOnlyTheSuccessfulSuffixAndPreservesExactMinimumIndependencecovers and calls
Other tests reaching this symbol 20
BytePlanCompilerTestcallsPlanBuilderTestcallsCompletionMemoTestcallsCompletionReductionTestcallsConstrainedCompletionTestcallsConstraintDependenciesTestcallsDerivationTestcallsDerivationTraceTestcallsTokenGeneratorTestcallsLexemeSequenceTestcallsCandidateResolverTestcallsSqlGeneratorTestcallsTerminalSequenceTestcallsGenerationContextTestcallsMySqlProviderTestcallsGenerationContextTestcallsPostgreSqlProviderTestcallsSqlGeneratorFactoryTestcallsGenerationContextTestcallsSqliteProviderTestcalls