Skip to content

fix(reflective): plumb slot_count from CostRecord — computeLegacyScalar / rawObjectiveVector (PKT-542) - #448

Open
bugsyhewitt wants to merge 1 commit into
mainfrom
feat/pkt-542-slot-count-plumbing
Open

fix(reflective): plumb slot_count from CostRecord — computeLegacyScalar / rawObjectiveVector (PKT-542)#448
bugsyhewitt wants to merge 1 commit into
mainfrom
feat/pkt-542-slot-count-plumbing

Conversation

@bugsyhewitt

Copy link
Copy Markdown
Owner

Problem

computeLegacyScalar and rawObjectiveVector both hardcoded slot_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 with correctness=1.0:

  • Python parity target: 1.0 × 1/(1 + 0.1 × max(0, 4−4)) = 1.0
  • Bug: 1.0 × 1/(1 + 0.1 × max(0, 4−1)) = 0.769

This broke Python↔TS parity and biased Pareto selection toward 1-slot genomes.

Fix (Option A — signature-preserving)

  • Add readonly slotCount?: number to CostRecord in types.ts
  • Replace the tautology/literal with cost.slotCount ?? 1 in both functions
  • Wire slotCount = candidate.toolSlots.length || 1 into all three adapters' cost records (mock-adapter already used toolCount; graph adapters add the field)

Tests

Added makeTraceWithSlots helper + 5 regression tests:

  • computeLegacyScalar: slot=4/calls=4 → 1.0 (no penalty); slot=4/calls=6 → 0.8/1.2; omitted fallback to 1
  • rawObjectiveVector: slot=4/calls=4 → efficiency 1.0; omitted fallback

Full suite green: TS 2171 passed, Python 1206 passed.

Files changed (6, packet-scoped)

  • src/alienclaw/evolution/reflective/types.ts
  • src/alienclaw/evolution/reflective/objectives.ts
  • test/evolution/reflective/mock-adapter.ts
  • src/alienclaw/evolution/graph/subagent-adapter.ts
  • src/alienclaw/evolution/graph/topology-adapter.ts
  • test/evolution/reflective/objectives.test.ts

Packet: PKT-542. Architect review: APPROVED (both task and whole-branch).

…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>
@bugsyhewitt bugsyhewitt added the auto-merge-ok Binding review passed + ship-gate green — cleared for auto-merge label Aug 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-ok Binding review passed + ship-gate green — cleared for auto-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant