Skip to content

refactor(apple): give the foreground probe one result shape - #4267

Merged
thymikee merged 1 commit into
mainfrom
chore/runner-bridge-followups
Nov 6, 2026
Merged

thymikee merged 1 commit into
mainfrom
chore/runner-bridge-followups

Conversation

@thymikee

@thymikee thymikee commented Nov 6, 2026 •

Copy link
Copy Markdown
Member

This PR applies the optional review items from #4256 and #4257 (#4256 (comment), #4257 (comment)). It does not change behavior.

  • One probe result shape. SystemSurfaceForegroundProbe now always returns { foreground, sessionId? }, so the three narrowings in snapshot-route.ts are gone. Only a channel that passes sessionChanged swaps circuits, and a runner-session refusal still disables the bridge only for a circuit that names its session.
  • Realistic fakes. Test fakes without a runner session now answer 'unknown', as the real probe does. Because 'unknown' sends surface hosts to the bridge read, the fake runner refuses that check only when a test sets refuseSurfaceHostCheck.
  • Native wedge test. After the admitted read, the test holds one more read and calls at a time far past the old abandon stamp. It asserts bridge-read-in-flight.
  • lease.ts uses the existing errorMessage(error) helper.

The #4257 description is also corrected: 14 files, and the check receipt for its merged head.

Native evidence: The runner was built with AGENT_DEVICE_XCUITEST_INCLUDE_UNIT_TESTS=1 (Xcode 26.2) and run with xcodebuild test-without-building -only-testing:AgentDeviceRunnerUITests/RunnerTests/testAbandonedReadBecomesWedgedUntilItReturns on a dedicated iOS 26.2 Simulator. It executed 1 test with 0 failures. With both RunnerSnapshotBridgeAbandonedAt = 0 resets removed, the same test fails at the new bridge-read-in-flight assertion (line 100).

TS: packages/platform-apple and the lease handler tests pass (1581 tests).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff Turn on auto-fix

Validation: tested at ae570e9. pnpm check:affected --run --head ae570e9d06 passed with exactCommit=true (format, lint, typecheck, layering, fallow, native-dupes, build, vitest-related, unit, xctest-selection, packaged-runner-swift).

- SystemSurfaceForegroundProbe always returns { foreground, sessionId? }, so the
  snapshot route drops its three narrowings.
- Test fakes without a runner session answer 'unknown', as the real probe does.
- The native wedge test holds a read after the admitted one and checks it at a
  time far past the old abandon stamp, so it fails if the stamp is not cleared.
- The lease handler uses errorMessage() for the teardown diagnostic.

Follow-up to #4256 and #4257.
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.15 MB 6.15 MB -150 B
Package (unpacked) 6.15 MB 6.15 MB -150 B
Package (download) 1.86 MB 1.86 MB -31 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 19.7 ms 18.5 ms -1.2 ms
CLI --help 39.8 ms 42.0 ms +2.2 ms

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel

Verdict: approve

No findings.

2 findings below minor not shown (user_settings.min_severity).

Reviewed with this repository's own Sentinel configuration (0a3b01890d53).

Reply under an inline comment with @apex-sentinel-staging note ... or @apex-sentinel-staging pivot ... to re-check that finding.
Comment @apex-sentinel-staging review on this conversation to run a full review.

@thymikee

thymikee commented Nov 6, 2026

Copy link
Copy Markdown
Member Author

At ae570e9 the probe now returns one { foreground, sessionId? } shape, and each route site reads the field it needs, with no behavior change in circuit selection or the local AX route. All checks pass and there are no conflicts.

Not blocking, and you can take or leave these: the PR also carries the lease.ts cleanup for #4257 and a Swift wedge assertion for #4256, which do not touch the foreground probe; the body does not give the tested SHA or the check:affected --run --head receipt that docs/agents/pull-requests.md asks for under Validation; the new block in RunnerTests+SnapshotBridgeTests.swift has no comment saying it pins the stale abandon stamp, and the expectation name "second read outlives its budget" describes the later event, so one line saying a read admitted after an abandoned one must not inherit the old stamp, plus a rename to say it only drains the second read, would help; and Awaited<ReturnType<SystemSurfaceForegroundProbe>> is spelled at snapshot-route.ts lines 211 and 454, so system-surface-foreground.ts could export SystemSurfaceForegroundReading and use it in the probe signature and both places.

The open thread (#4267 (comment)) does not apply: the in-flight assertion is on purpose, because the second read is still inside its 1000 ms budget and the test targets the stale AbandonedAt from the first read, which RunnerSnapshotBridge.m clears at lines 225 and 239. It can be resolved.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 6, 2026
@thymikee
thymikee merged commit a68693c into main Nov 6, 2026
17 checks passed
@thymikee
thymikee deleted the chore/runner-bridge-followups branch November 6, 2026 11:56
thymikee added a commit that referenced this pull request Nov 6, 2026
Export SystemSurfaceForegroundReading and use it in the probe signature and both
route sites. The native wedge test block now says it pins the stale abandon
stamp, and its expectation names the abandonment it waits for.

Follow-up to #4267.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant