Skip to content

fix: restore runnerRoundTrips agent-cost field dropped in #968#970

Merged
thymikee merged 1 commit into
mainfrom
restore-runner-round-trips
Jul 1, 2026
Merged

fix: restore runnerRoundTrips agent-cost field dropped in #968#970
thymikee merged 1 commit into
mainfrom
restore-runner-round-trips

Conversation

@thymikee

Copy link
Copy Markdown
Member

Regression

PR #968 (apple-platform-consolidation, merge 26ac865c6) accidentally removed the runnerRoundTrips field from the agent-cost block — a shipped Phase-4 feature. The removal was an over-broad conflict resolution: the merge intended to keep main's round-trip wiring, but it got dropped. The commit message is just "refactor: consolidate Apple platform internals" with no mention of dropping the feature, and the cost graft's call site still carries the comment "Runs inside the diagnostics scope so cost can read this request's runner-round-trip tally" — i.e. the intent was preserved while the implementation was lost.

On the regressed main, runnerRoundTrips appeared nowhere in src/: ResponseCost had only wallClockMs + optional nodeCount, and the request-router cost graft only set wallClockMs.

What was restored

  • src/kernel/contracts.ts — re-add ResponseCost.runnerRoundTrips: number (always present when cost is included; 0 when no runner was hit).
  • src/utils/diagnostics.ts — restore the countDiagnosticEventsByPhase() accessor over the flush-surviving phaseCounts tally. The tally mechanism itself (phaseCounts map on the diagnostics scope, populated in emitDiagnostic) survived refactor: consolidate Apple platform internals #968; only the public accessor was removed, so this re-adds just the accessor.
  • src/daemon/request-router.ts — repopulate runnerRoundTrips in buildResponseCost by counting the two real round-trip diagnostic phases (ios_runner_command_send + ios_runner_readiness_preflight). The graft already runs inside the request's diagnostics scope, so it reads the per-request tally. The RUNNER_ROUND_TRIP_PHASES constant is now defined locally in this file: its former home, the dev-only runner-request-count.ts CI gate, was removed in refactor: consolidate Apple platform internals #968 and is intentionally out of scope to restore (a separate maintainer decision).
  • src/daemon/__tests__/request-router-cost.test.ts — restore the runnerRoundTrips: 0 assertion in the additive-only test and re-add the round-trip counting test (1 preflight + 2 command_send = 3, excluding _skipped/unrelated phases).

Out of scope (intentionally not restored)

The dev-only ndjson gate deleted by #968 (scripts/runner-request-count/, src/daemon/runner-request-count.ts) — a separate maintainer decision. Only the runnerRoundTrips agent-cost field is restored here.

Invariant preserved

Byte-identical-default: with --cost OFF (or on an error response) the serialized response is unchanged. The cost block is still purely additive on the success path.

Verification

  • tsc -p tsconfig.json --noEmit — 0 errors
  • vitest run request-router-cost.test.ts — 6/6 pass
  • oxfmt --check + oxlint --deny-warnings on all 4 changed files — clean
  • fallow audit --base origin/main — no issues
  • rslib build — success

PR #968 (apple-platform-consolidation) accidentally dropped the
runnerRoundTrips field from the agent-cost block during an over-broad
conflict resolution. This restores the shipped Phase-4 feature:

- src/kernel/contracts.ts: re-add ResponseCost.runnerRoundTrips: number
- src/utils/diagnostics.ts: restore the countDiagnosticEventsByPhase()
  accessor over the flush-surviving phaseCounts tally (the tally itself
  survived #968; only the accessor was removed)
- src/daemon/request-router.ts: repopulate runnerRoundTrips in the cost
  graft by counting the two real round-trip diagnostic phases
  (ios_runner_command_send + ios_runner_readiness_preflight). The
  RUNNER_ROUND_TRIP_PHASES constant is now defined locally (its former
  home, the dev-only runner-request-count.ts, was removed in #968 and is
  out of scope to restore)
- request-router-cost.test.ts: restore the round-trip counting test and
  the runnerRoundTrips:0 assertion

Byte-identical-default invariant preserved: with --cost OFF or on an
error response the serialized payload is unchanged.
@github-actions

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.4 MB 1.4 MB +268 B
JS gzip 450.4 kB 450.5 kB +123 B
npm tarball 549.7 kB 549.9 kB +164 B
npm unpacked 1.9 MB 1.9 MB +361 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.9 ms 27.8 ms -0.1 ms
CLI --help 47.6 ms 47.9 ms +0.3 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/9722.js +127 B +75 B

@thymikee

Copy link
Copy Markdown
Member Author

Review finding for head 5ef1e70:

plans/phase3-platform-plugin-progress.md still says the cost.runnerRoundTrips runtime surface was removed in #968, but this PR intentionally restores that public agent-cost field. If this lands as-is, the plan becomes stale/misleading for the next Apple/agent-cost worker. Please update the Step (c) request-count bullet to distinguish the dev-only request-count CI gate, which remains removed, from the restored runtime cost.runnerRoundTrips surface.

@thymikee thymikee merged commit f9445d0 into main Jul 1, 2026
21 checks passed
@thymikee thymikee deleted the restore-runner-round-trips branch July 1, 2026 05:24
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-01 05:24 UTC

thymikee added a commit that referenced this pull request Jul 1, 2026
…n Phase 3 plan (#971)

The Step (c) request-count bullet claimed both the dev-only CI gate AND the
runtime `cost.runnerRoundTrips` surface were removed in #968. #970 restored the
public agent-cost field, so the bullet is stale/misleading for the next
Apple/agent-cost worker.

Split the bullet: the dev-only request-count CI gate (the #966 --debug ndjson
counter + smoke-ios assertion) stays removed (zero runner events on main runs);
the runtime `cost.runnerRoundTrips` agent-cost field (ResponseCost /
buildResponseCost over RUNNER_ROUND_TRIP_PHASES) is a separate pre-existing
surface, restored in #970, and remains part of the agent-cost contract.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant