A CI selector makes a decision about what to test from a list of changed paths. An earlier Engineering article asked where that list should come from. This time we held the comparison range fixed and looked at what happened after the list was available. We expected a selector to recognize a matching entry whether it appeared near the beginning or the end. In a local regression harness, the older selector selected a check when the one relevant entry was late in a large synthetic list. In the early case it left that check out. The revised selector made the expected choice in both cases.

A match and a successful command are different observations

A search for the presence of an entry can stop as soon as it finds one. That is a useful property when the search reads a file on its own. In a pipeline the search shares responsibility for the overall outcome with another process. A producer can still be writing when a consumer decides it has read enough. If the consumer closes its end while the producer has more data to send, the producer can terminate with a broken pipe. A shell configured to report a failed stage can then treat the whole pipeline as unsuccessful even when the search did find a match.

That mechanism is consistent with the difference between the early and late fixtures. The harness recorded the resulting flags and exit status. It did not capture the individual search and writer statuses for the missed match, so the pipeline explanation remains an inference from the code and the observed pattern. Moving the match changes when a search can finish. The size of the list and the way the shell schedules its processes can also affect whether the writer has finished by then. The fixtures give us a comparison on this setup, with no portable file count at which to expect the difference.

Give a search error its own outcome

The revised selector writes the list to a temporary file and uses the file as the search input. The search can still finish when it finds a match. It has no streaming producer that needs to finish at the same time. The selector also distinguishes a completed search with no match from a search error. Reading the revised code shows that an error requests the full set of checks. We exercised successful searches and normal no-match results in the fixtures. We did not inject a search error to observe the fallback.

Two controls show why the inputs deserve separate cases. A large list containing documentation changes alone selected none of the checks tracked by the harness. An empty diff selected all of them under the tested policy. Those inputs both lack a relevant path, but only one contains a list of changes for the selector to classify. Putting both cases in the regression harness tests what the policy does as well as what the matcher sees.

Check diagnostics after the decision

The older selector also had a short diagnostic preview that could close a pipe early. In six large-list validations it emitted routing flags and then exited with status 141, consistent with broken-pipe termination on the local host. The revised preview limits the lines it prints while continuing to read the input. In those same validations the revised selector returned the expected flags, printed a reason and exited successfully. A harness that checked only whether the output contained flags would miss the distinction between a completed decision and a command that failed after writing those flags.

The regression harness reported 48 passing validations against the merged selector. The same harness reported nine failures against its predecessor. A CI run separately logged successful early and late cases on a revision with the same selector and harness. These are results for routing output and command status. They leave open whether any historical run omitted a job for this reason, how frequently the mismatch could occur and how much time the change saves. We can ask a more concrete question of a future change to the selector. Given the same list, did it choose the expected checks, explain its choice and finish successfully?

← All engineering articles