fix(reflective): plumb slot_count from CostRecord — computeLegacyScalar / rawObjectiveVector (PKT-542) - #448
Open
bugsyhewitt wants to merge 1 commit into
Open
fix(reflective): plumb slot_count from CostRecord — computeLegacyScalar / rawObjectiveVector (PKT-542)#448bugsyhewitt wants to merge 1 commit into
bugsyhewitt wants to merge 1 commit into
Conversation
…Scalar and rawObjectiveVector (PKT-542) Previously both functions hardcoded slot_count=1, breaking Python parity and unfairly penalising multi-slot genomes. This adds CostRecord.slotCount? (optional, back-compat) and reads it with ?? 1 fallback in both objective helpers. Three adapters (mock, subagent, topology) now write slotCount into CostRecord. Five new regression tests cover slot-aware and back-compat paths. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
computeLegacyScalarandrawObjectiveVectorboth hardcodedslot_count = 1(one via a tautological ternary, one via a literal), causing a multi-slot genome that makes exactly k tool calls to be penalised as if it were 1-slot. For a 4-slot genome withcorrectness=1.0:1.0 × 1/(1 + 0.1 × max(0, 4−4)) = 1.01.0 × 1/(1 + 0.1 × max(0, 4−1)) = 0.769This broke Python↔TS parity and biased Pareto selection toward 1-slot genomes.
Fix (Option A — signature-preserving)
readonly slotCount?: numbertoCostRecordintypes.tscost.slotCount ?? 1in both functionsslotCount = candidate.toolSlots.length || 1into all three adapters' cost records (mock-adapter already usedtoolCount; graph adapters add the field)Tests
Added
makeTraceWithSlotshelper + 5 regression tests:computeLegacyScalar: slot=4/calls=4 → 1.0 (no penalty); slot=4/calls=6 → 0.8/1.2; omitted fallback to 1rawObjectiveVector: slot=4/calls=4 → efficiency 1.0; omitted fallbackFull suite green: TS 2171 passed, Python 1206 passed.
Files changed (6, packet-scoped)
src/alienclaw/evolution/reflective/types.tssrc/alienclaw/evolution/reflective/objectives.tstest/evolution/reflective/mock-adapter.tssrc/alienclaw/evolution/graph/subagent-adapter.tssrc/alienclaw/evolution/graph/topology-adapter.tstest/evolution/reflective/objectives.test.tsPacket: PKT-542. Architect review: APPROVED (both task and whole-branch).