feat(workflows): selection math — seeded PPT primitives (V4, #2488) - #2512
Conversation
| const other = Math.floor(rng() * (index + 1)); | ||
| [permutation[index], permutation[other]] = [permutation[other]!, permutation[index]!]; | ||
| } | ||
| return permutation.map((a, index) => ({ a, b: permutation[(index + 1) % n]! })); |
There was a problem hiding this comment.
Two-candidate ring schedules the sole comparison twice
For n === 2, the modulo successor mapping produces both {a: 1, b: 0} and {a: 0, b: 1}. These are the same unordered comparison, but jobs schedules both directions and accumulate incorporates both results, giving each candidate a count of 2 for a single criterion/repeat. Return one deterministic pair for two candidates, or deduplicate before creating jobs, so the only matchup is evaluated once.
Artifacts
Two-candidate Hamiltonian-ring executable probe source
- Executable source imports the production planner, job builder, score normalization, and accumulator, then checks the two-candidate scheduling path; it is the exact code run to establish the duplication.
Two-candidate Hamiltonian-ring observed output before comparison
- Executed `bun trex-artifacts/hamiltonian-ring-n2-probe.mts` from `/home/user/repo` with exit code 0; it shows reciprocal ring pairs, two jobs, and accumulated counts `[2,2]`, confirming duplicate evaluation.
Two-candidate Hamiltonian-ring observed output after comparison
- Second executed capture of the same unchanged production code with exit code 0; it reproduces the reciprocal ring pairs, two jobs, and counts `[2,2]`, confirming the observation is stable.
Existing selection-math unit test result
- Executed the focused repository unit suite with `npx --no-install vitest --run --project unit test/unit/selection-math.test.ts`; all 9 existing tests pass, showing this n=2 downstream consequence is currently untested.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/workflows/builtin/selection-math.ts
Line: 57
Comment:
**Two-candidate ring schedules the sole comparison twice**
For `n === 2`, the modulo successor mapping produces both `{a: 1, b: 0}` and `{a: 0, b: 1}`. These are the same unordered comparison, but `jobs` schedules both directions and `accumulate` incorporates both results, giving each candidate a count of 2 for a single criterion/repeat. Return one deterministic pair for two candidates, or deduplicate before creating jobs, so the only matchup is evaluated once.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| - Added prefix-cache-aware verification prompts with a byte-identical shared head, UTF-8 bounded candidate inlining with whole-family read fallback, and warm-first verifier fan-out scheduling that preserves input order while releasing later phases after warm failures ([#2493](https://github.com/bastani-inc/atomic/issues/2493)). | ||
| - Added pure, seeded selection math for probabilistic pivot tournaments: deterministic Hamiltonian ring and deduplicated pivot planning, criterion/repeat slot-swap jobs, normalized Bradley–Terry soft wins, count-normalized pivot selection, and complete candidate rankings ([#2488](https://github.com/bastani-inc/atomic/issues/2488)). |
There was a problem hiding this comment.
Alpha.4 release history is removed
This update drops both the adversarial-verification entry and the ## [0.9.14-alpha.4] - 2026-08-18 heading that were present in the prior changelog. The unreleased entries now flow directly into 0.9.14-alpha.3, making the released alpha.4 changes and their version boundary disappear. Restore the alpha.4 heading and its associated entry after the Unreleased section.
Artifacts
Executed changelog deletion check source
- The runnable Bash check reads base and HEAD changelog Git objects and compares the exact entry and heading, ending with a nonzero result when HEAD lacks them.
Executed changelog deletion check output showing missing alpha.4 history in HEAD
- The captured run shows both records at base lines 19-20, no matching HEAD records, and `RESULT=DELETED_FROM_HEAD`; takeaway: the claimed deletion is confirmed.
Ran code and verified through T-Rex
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/workflows/CHANGELOG.md
Line: 19-20
Comment:
**Alpha.4 release history is removed**
This update drops both the `adversarial-verification` entry and the `## [0.9.14-alpha.4] - 2026-08-18` heading that were present in the prior changelog. The unreleased entries now flow directly into `0.9.14-alpha.3`, making the released alpha.4 changes and their version boundary disappear. Restore the alpha.4 heading and its associated entry after the Unreleased section.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
Summary
Slice V4 of the LLM-as-a-Verifier adoption program (
specs/2026-08-17-tournament-soft-selection.md§5.1): the pure, dependency-free selection-math primitives for the pivot-pairing tournament.packages/workflows/builtin/selection-math.ts(new, no ctx / no I/O / no model calls):seeded_rng— mulberry32-class, cross-platform deterministicplan_comparisons({n, pivots, repeats, seed})→ComparisonPlan: seeded Hamiltonian ring (every candidate once per slot), pivot rounds (non-pivot×pivot + pivot×pivot minus pairs already in the ring), jobs expanded × criteria × repeats with odd reps slot-swapped; refuses n<2, pivots<1, repeats<1; no pair scheduled twicesoft_win(a,b)— sigmoid over scores normalized fromVERIFICATION_SCALE1..20 to [0,1] (raw differences would saturate)accumulate,select_pivots(top-k by w/c, ties by lower index),rank_candidates(length always n; c=0 defined as 0)Base:
verifier/prefix-cache-prompts(V3, #2510). Stack: V1 → V3 → V4 → V5 → V6.Evidence
Produced by an implement→review→repair goal run (approved in 1 turn; completion/evidence/risk reviewers all
complete;remaining_work: none):npm run check— green (includes the coding-agent tsgoerasableSyntaxOnlypass)npx vitest --run --project unit -t "selection-math"— green: seeded RNG reference vectors, valid Hamiltonian ring adjacency, deep-equal plan determinism under a fixed seed, ring∩pivot dedup, odd-rep slot-swap bookkeeping, Σc = 2×comparisons, pivot tie-break by lower index, ranking length always n, comparison budget ≤ N + k(N−k) + C(k,2)packages/workflows/CHANGELOG.mdunder## [Unreleased]### AddedSpec contract:
specs/2026-08-17-tournament-soft-selection.md§5.1 (Q1–Q3: pivots 1, n_evaluations 2, seed 0).Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Greptile Summary
This change adds deterministic selection math for tournament planning and records the feature in the workflows changelog. Two-candidate plans currently schedule the same unordered matchup in both directions, causing duplicate evaluation and accumulated comparison mass. The changelog update also removes the existing 0.9.14-alpha.4 release heading and its adversarial-verification entry. The focused selection-math unit suite passes but does not cover the two-candidate planning path.
Confidence Score: 3/5
Not safe to merge until two-candidate tournament planning avoids reciprocal duplicate jobs and the removed alpha.4 changelog history is restored.
Two independent, non-security functional issues were reproduced with targeted executable checks: duplicate planning and accumulation for two candidates, and removal of prior release-history content.
Files Needing Attention: packages/workflows/builtin/selection-math.ts needs a two-candidate deduplication path; packages/workflows/CHANGELOG.md needs the 0.9.14-alpha.4 heading and adversarial-verification entry restored.
What T-Rex did
Comments Outside Diff (2)
General comment
packages/workflows/builtin/selection-math.ts:57, modulo wrapping maps both permutation positions in ann=2cycle to the same unordered pair in opposite directions. The executed path scheduled two jobs for criterionqualitywithrepeats: 1, then accumulated two preferences and counts[2,2]. Thus the sole pair receives double evaluation and double total weight/count mass.ring_cyclealways returns one edge per vertex. In a directed 2-cycle, those edges are reciprocal representations of the same unordered pair, while later planning/jobs do not deduplicate ring entries.n === 2inring_cycle(or deduplicate the ring before job creation) so it returns exactly one directed pair. Preserve one orientation deterministically from the shuffled permutation.General comment
packages/workflows/CHANGELOG.md, base commitd82b11ddhas the adversarial-verification fan-out/mean-veto entry at line 19 and## [0.9.14-alpha.4] - 2026-08-18at line 20. At HEAD, both are absent: current lines 19-20 are unrelated Unreleased entries, followed by### Fixed, and the next release heading is0.9.14-alpha.3at line 26. This confirms unrelated release history/version-boundary loss.## [0.9.14-alpha.4] - 2026-08-18and its adversarial-verification entry immediately after the Unreleased section, preserving the existing alpha.3 boundary below it.Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "merge origin/main" | Re-trigger Greptile