Reconstruct and merge ordered inputs without general sorting

This commit is contained in:
2026-11-07 12:10:40 +00:00
parent d72c9a788f
commit 7bb7326ed1
4 changed files with 145 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
# Shared reporting and PromptKit adoption remediation
Status: two open findings; R1–R5 complete. R1–R3 are from the architectural review of
Status: one open finding; R1–R6 complete. R1–R3 are from the architectural review of
`f83866e44a8a9066db52cbd2aa5cccde0d69a839`. R4–R7 are from the algorithmic
audit of `f5b2d1f80c4720b762f3301c29d5050710c210d0`; R4 is a correctness
issue and R5–R7 are efficiency opportunities for consideration.
@@ -243,6 +243,15 @@ threshold or benchmark is needed to establish the complexity difference.
## R6 — P3: Ordered inputs use general sorting of already indexed streams
**Complete.** Initial preparation places ordered setters at parser positions
and scans them once, using O(M+F) traversal and O(M) ordering storage. Captured
replay uses a standard-library heap to merge K monotone streams in O(K+E log K)
work for K greater than one, O(E) for one stream, and O(K) merge storage.
Selection order breaks ties, preserving duplicate handles. Core regressions cover
nested capture, reversed/subset/single/empty/duplicate selections, both replay
methods, conversion counts, and repeated invocations. The independent core and
aligned ckconfig/ckprompt suites pass with Go 1.27.0.
**Location:** [binding.go](../../binding.go), prepareInputWithOccurrences line
316, and [flag_values.go](../../flag_values.go), FlagValues.applyTo line 122.