Skip to content

test: wait on signals, not timeouts, in the chip-pass and workspace-registry tests - #1788

Merged
uzairansaruzi merged 2 commits into
masterfrom
issue/1784-untimed-waits
Nov 20, 2026
Merged

uzairansaruzi merged 2 commits into
masterfrom
issue/1784-untimed-waits

Conversation

@uzairansaruzi

@uzairansaruzi uzairansaruzi commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Linked issue

Fixes #1784

What changed

Three ordering tests could pass without proving the order they claim. The chip-pass test assumed one Task.yield() was enough for the second loadFileChipReferences caller to start waiting behind the first. The two stale-response workspace tests held the first response behind a semaphore with a 2-second timeout, so the hold could end on its own.

Each test now waits on a signal:

  • The second chip-pass task fulfils an expectation right before it calls in, and the test awaits that expectation. Both run on the main actor, so the test can't resume until the second caller has suspended in the wait loop. No production hook was needed.
  • The workspace tests hold the stale response with a plain wait() that the test releases itself, the same pattern TaskRunHistoryTests uses. The rename test now unwraps its beta row before the held request starts, so a failed lookup can't leave the mock queue blocked.

How it was tested

  • scripts/test-sim <udid> --repeat 50 --only on the three tests: 50/50 each. After rebasing onto chore/ban-comments: --repeat 20, 20/20 each.
  • Fault check (production code restored afterwards):
    • With the source check moved above the wait loop in ChatViewModel.loadFileChipReferences, the chip test fails (complete.path writes 2 ≠ 1).
    • With guard !superseded deleted from WorkspaceRegistryViewModel.performMutation, both workspace tests fail: the stale order and the removed workspace come back.
  • python3 ci/check_test_waits.py, python3 ci/check_comments.py, python3 -m unittest discover -s ci -p 'test_*.py': pass.

Checklist

  • Local validation passes using scripts/test-sim <assigned-simulator-udid> with the tests required by AGENTS.md § Verifying; the selection and results are recorded above
  • New/changed Codable models decode tolerantly (optionals for fields the server might add or rename)
  • No new third-party dependencies (the list in AGENTS.md is locked)
  • No invented API endpoints or JSON shapes (verified against upstream source or a running server)

Reviewed with sol-loop: 2 rounds with gpt-6.2-sol. Sol verdict: approved

Created with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
Walkthrough

Three tests now use explicit signals or gates to control request ordering. The chip-pass test waits for the second lookup to start. The workspace-registry tests block reorder and rename requests until released, and the stale-rename test captures beta before starting the rename task.

Changes: Test synchronization

Layer / File(s) Summary
Chip-pass lookup ordering
HermesMobileTests/HermesChatTurnTests.swift
The test waits for a signal that confirms the second file-chip lookup started, replacing Task.yield() synchronization.
Workspace mutation ordering
HermesMobileTests/WorkspaceRegistryViewModelTests.swift
The reorder and rename requests wait for semaphore signals instead of timing out. The stale-rename test captures beta before starting the rename task.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Suggested reviewers: audichuang

Merge Risk: Low · previous review 60314

This PR only makes three ordering tests more deterministic and does not change app behavior. One chip-pass test can still fail spuriously if the test runner stalls for several seconds. It is safe to merge, and a test-controlled gate for the first lookup could be a later follow-up.

Security architecture risk: Minimal · up to 60314

The changes make three asynchronous tests coordinate explicitly. They do not introduce or worsen a material security or architecture risk.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #1784 is the only active direct target. Its coding requirements are: (1) remove the Task.yield() ordering assumption from HermesChatTurnTests.testAWaitingChipPassRechecksTheBackend; (2) remove t… Provide readable text of the changed hunks or blobs for HermesMobileTests/HermesChatTurnTests.swift and HermesMobileTests/WorkspaceRegistryViewModelTests.swift at the reviewed head, or a narrowed read of the chip-pass test and the two works…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title "test: wait on signals, not timeouts, in the chip-pass and workspace-registry tests" matches the main change. The raw summary and objectives show the PR replaces timed waits and Task.yield()…
Out of Scope Changes check Passed The PR summary and the raw summary both state that only two test files changed: HermesChatTurnTests.swift (+6/-2) and WorkspaceRegistryViewModelTests.swift (+3/-3). The chip-pass test change adds an e…
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title "test: wait on signals, not timeouts, in the chip-pass and workspace-registry tests" matches the main change. The raw summary and objectives show the PR replaces timed waits and Task.yield() ordering assumptions with explicit signals in the chip-pass test (HermesChatTurnTests) and the stale-response workspace registry tests. The title names the two areas touched and the core change. It is slightly long at 82 characters, but it is specific and accurate.

Full details: Out of Scope Changes check

Explanation

The PR summary and the raw summary both state that only two test files changed: HermesChatTurnTests.swift (+6/-2) and WorkspaceRegistryViewModelTests.swift (+3/-3). The chip-pass test change adds an expectation signal before the second loadFileChipReferences call. The workspace changes replace timed semaphore waits with released waits and move the beta row capture before the rename request. The PR description states that no production code changed; the fault-check notes say production code was restored after testing. All changes map to the three tests named in #1784. The ci/ script runs are validation steps, not changes. Limit: the diff text could not be read, so the line-level content is based on the summaries and the PR description.

Full details: Linked Issues check

Explanation

Issue #1784 is the only active direct target. Its coding requirements are: (1) remove the Task.yield() ordering assumption from HermesChatTurnTests.testAWaitingChipPassRechecksTheBackend; (2) remove the DispatchSemaphore timeout from WorkspaceRegistryViewModelTests.testStaleReorderResponseDoesNotClobberNewerOrder and testStaleRenameResponseDoesNotResurrectRemovedWorkspace; (3) make each test fail when its named behavior breaks; (4) pass python3 ci/check_test_waits.py. The PR description states that each change was made and that fault checks were run. The PR summary describes the same changes. Repository diff reads for both changed test files failed because the changed blobs are missing from the checkout. A file read of HermesChatTurnTests.swift at head returned only the first part of the file (truncated at 16000 bytes), and the chip-pass test was not in the returned text. I could not confirm the edited test bodies, the absence of Task.yield() or timeout calls, or the fault-check results. Stack evidence is unavailable; the objective is test-only and needs no stack members. Scope of the requirements is limited to the three named tests.

Resolution

Provide readable text of the changed hunks or blobs for HermesMobileTests/HermesChatTurnTests.swift and HermesMobileTests/WorkspaceRegistryViewModelTests.swift at the reviewed head, or a narrowed read of the chip-pass test and the two workspace tests. Confirm that no Task.yield() ordering assumption and no semaphore timeout remain in the three tests. Include the output of python3 ci/check_test_waits.py at the reviewed head.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@greptile-apps

greptile-apps Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Summary

The PR replaces timing assumptions with explicit signals in three ordering tests.

  • The ordering tests wait for the work they need to observe.
  • PR CI checks test waits and tracks source-comment changes.
  • App and test source files contain fewer comments.

No actionable issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "test: wait on signals in the chip-pass a..." · Reviewed by Greptile

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor comments: 1

HermesMobileTests/HermesChatTurnTests.swift: 1

1090-1095: Minor · Functional Correctness · Poor tradeoff

Keep the first pass pending until the backend changes.

An unusually long scheduling delay can let the five-second RPC deadline expire before the second pass starts. The second pass can then retry on the local backend and cause a false failure on the complete.path write count.

Use a test-controlled gate that is not subject to the RPC deadline, and release it after the backend change.

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d03587b and 6031495.

Files selected for processing: 2

  • HermesMobileTests/HermesChatTurnTests.swift
  • HermesMobileTests/WorkspaceRegistryViewModelTests.swift

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

@uzairansaruzi

Copy link
Copy Markdown
Owner Author

Note

🤖 Claude Fable 5.2 responding on behalf of uzairansaruzi

Not changing the rpcDeadline point from CodeRabbit's review. The 5 s deadline predates this PR (openChat(rpcDeadline: .seconds(5)) is on the base) and the test no longer waits on it: both passes are released by the session.info event the test sends. It would only matter if the runner stalled for more than five seconds between two consecutive awaits, and replacing the deadline with a second gate adds test machinery for that case alone. The test passed 50 of 50 and 20 of 20 repeated runs.

uzairansaruzi and others added 2 commits November 20, 2026 13:37
…1789)

## Linked issue

No issue: a maintainer-requested chore.

## What changed

About 10% of our Swift was comments (28,500 of them, 29,000 lines). Most
restated the code, a few gave cover to shortcuts, and the ones that
recorded a real decision were scattered where nobody looks for
decisions. This PR deletes them and bans new ones.

- **Every comment was classified** as a tautology, stale, an excuse, or
a decision record. The decision records are now 180 ADRs holding 979
decisions under `docs/adr/` (format in `docs/adr/README.md`). The
excuses became #1781, #1782, #1783, #1784 and #1785.
- **The comments are gone**: 29,032 lines across 665 Swift files. Two
third-party licence notices stay (`ReviewDiffCanvasView.swift`,
`BotProfileAppearance.swift`) because no file in `ThirdPartyNotices/`
covers them yet, and so do the `// test-wait:` annotations
`ci/check_test_waits.py` reads.
- **`ci/check_comments.py` fails a Swift file that gains a comment.** It
runs in Tooling Tests. `ci/comment_baseline.txt` lists the two files
that still hold comments; a count there only goes down, and a pull
request cannot raise it past the target branch's.
- **The `delete-comment` skill** (`.agents/skills/delete-comment`,
linked from `.claude/skills`) repeats the sweep for whatever is left.
`.gitignore` now tracks repo skills.
- **`AGENTS.md`** states the rule in Taste and points decisions at
`docs/adr/`.

Nothing but comments and the blank lines around them changes in Swift.

## How it was tested

- **Only comments changed.** An oracle built on the toolchain's
SwiftParser compared the token stream of all 701 Swift files with
`master`'s: none differ. The only comment trivia it finds at this head
are the 26 licence lines and 15 `// test-wait:` lines.
- **The checker finds what Swift finds.** Its scanner and SwiftParser
agree on every one of the 28,507 comments in the 701 files at the base.
- `python3 -m unittest discover -s ci -p 'test_*.py'`: 21 passed.
`python3 ci/check_comments.py` and `python3 ci/check_test_waits.py`
pass.
- `scripts/test-sim` on iPhone 17e, after the rebase onto current
`master`: 246 passed, 0 failed. The selection is the classes that read
source-relative fixtures or had a `test-wait` annotation rewritten, plus
the files `master` changed under the rebase: `HermesSlashCommandTests`,
`HermesInsightsClientTests`, `HermesChatSettingsTests`,
`LocalizationCatalogTests`, `HermesAgentFixtureTests`, `SSEClientTests`,
`KanbanLiveUpdateTests`, `CronManagementModelTests`,
`CronManagementViewModelTests`, `HermesCronClientTests`,
`HermesConversationTests`, `HermesBranchDuplicateTests`,
`ToolCallSummaryFormatterTests`. The full suite is left to this PR's CI.

## Checklist

- [x] Local validation passes using `scripts/test-sim
<assigned-simulator-udid>` with the tests required by `AGENTS.md` §
Verifying; the selection and results are recorded above
- [x] New/changed `Codable` models decode tolerantly (none changed)
- [x] No new third-party dependencies (the list in `AGENTS.md` is
locked)
- [x] No invented API endpoints or JSON shapes (none touched)

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol on high. Sol verdict:
changes requested in round 3 (a regex literal after a comment, stray
`test-wait` annotations, paths outside the checkout); all fixed in the
last commit, which Sol has not re-reviewed.

Created with Claude Fable 5.2 in Claude Code (T3 Code). Classification
and ADR drafting by Claude Opus 5.5 subagents.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
The chip-pass test assumed one Task.yield() put the second caller behind
the first pass; it now waits on an expectation the second task fulfils
right before it calls in. The two stale-response workspace tests held the
first response with a 2-second semaphore timeout; the test now releases
the gate itself.

Fixes #1784

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@uzairansaruzi
uzairansaruzi changed the base branch from chore/ban-comments to master November 20, 2026 18:38
@uzairansaruzi
uzairansaruzi force-pushed the issue/1784-untimed-waits branch from 6031495 to c2fc614 Compare November 20, 2026 18:38
@uzairansaruzi
uzairansaruzi merged commit ceab4f1 into master Nov 20, 2026
8 of 14 checks passed
@uzairansaruzi
uzairansaruzi deleted the issue/1784-untimed-waits branch November 20, 2026 19:26
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.

test: replace timed waits in the chip-pass and workspace-registry tests

1 participant