Skip to content

Enforce Rust formatting and Clippy gates - #38

Merged
yansfil merged 4 commits into
mainfrom
build/rust-format-lint-gates
Sep 10, 2026
Merged

yansfil merged 4 commits into
mainfrom
build/rust-format-lint-gates

Conversation

@yansfil

@yansfil yansfil commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What changed, in one paragraph a new contributor can follow

This change establishes the existing Rust source as a clean formatting and lint baseline, resolves every current Clippy finding, and makes cargo fmt --check plus locked all-target Clippy with warnings denied mandatory in both pull-request CI and the full local verification script. It also makes that full local script reproducible by selecting a supported UTF-8 locale, building the release library at the path the Swift package links, and keeping the fork-surface fixture away from an operator's configured remote machine.

Review boundary

  • Runtime mutex: No new work is performed while holding it; the Rust source changes are mechanical formatting, lint-equivalent rewrites, or narrowly documented lint allowances.
  • Snapshot wire: No field is added or moved; the generated pinned-schema module receives only boundary-scoped lint allowances.
  • Ownership: No Herdr-owned or core-owned value changes ownership, timing, or confirmation behavior.
  • Herdr contract: No method, parameter, or field outside contracts/herdr-api.schema.json is introduced.
  • Failure path: Formatting drift and any Clippy warning now fail the Rust CI job and the final verify job with the originating command's output; runtime user-visible failure behavior is unchanged.

Evidence

  • Verified by: bash scripts/check-hide-full.sh passed end to end: formatting and Clippy, 432 Rust tests with 6 ignored, 31 FFI tests, 362 Swift tests, repository invariants, the pinned Herdr schema checks, the design contract and its 6 tests, design lint with 0 errors and 0 warnings, and the final enforcement/CI binding checks. The exact CI commands also passed under local Rust 1.98.0 with rustfmt 1.9.0 and Clippy 0.1.98, matching the tools currently documented for GitHub's macos-15 runner: https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md#rust-tools
  • Verified by: the four requested names were inspected rather than deleted blindly. SNAPSHOT_FIELDS_THE_REPLICA_READS is a test-contract constant and is now test-only. FILE_LIMIT, LINE_LIMIT, and diagnostics install remain production FFI dependencies and are excluded only from test-target compilation where their caller is already absent.
  • Verified by: after automatic fixes, 40 unique all-target findings were classified. Generated pinned-schema warnings are allowed only at that boundary; the two high-frequency enum-size findings and two correlated-argument findings have targeted, documented allowances; production findings use a type alias, is_empty, contains_key, and reverse-key sorting.
  • Not verified (and why): no Swift formatting or lint gate was added because neither SwiftFormat nor SwiftLint is available both locally and on the selected runner. No native visual verification was run because this change has no visual surface.
  • High-frequency path impact (or N/A): no input, state publication, notification, allocation, or queue behavior changed. The event enums were deliberately not boxed merely to silence large_enum_variant, avoiding a new allocation on every synchronized event; existing Rust and Swift suites cover the affected paths.

Screenshots

N/A - no visual surface changed.

AI tooling

Machine assistance applied the mechanical cleanup and classified lint output. Every semantic rewrite and allowance was reviewed, and the full diff, exact gate commands, and complete verification suite were checked by hand.

@yansfil
yansfil merged commit 79cbaa5 into main Sep 10, 2026
5 checks passed
@yansfil
yansfil deleted the build/rust-format-lint-gates branch September 10, 2026 01:11
yansfil added a commit that referenced this pull request Oct 29, 2026
Closes with-hide/hide-private#37
Closes with-hide/hide-private#38
Closes with-hide/hide-private#307

## Summary

A resting Codex CLI was hard to wake and to write to.

- **#37, stray `9;5u` before the resume line.** Sleep pressed Ctrl+C
twice. Codex CLI quits on the first, so the second reached the shell.
Sleep now presses again only when the agent asks for it.
- **#307, letter stuck pending.** A bell whose reservation failed typed
nothing, yet waited for the pane to move. It now retries on the timer,
at most three bells.
- **#38, 429 read as failure.** A Codex CLI turn never answered, whose
conversation's newest retry is a 429, reads `not measured`. A check that
failed on its own beside that turn stays a failure.

스크린샷 없음: 화면을 바꾸지 않는 변경입니다 (셸 입력, 편지 재시도, journey 판정).

## Review

- **판단해 주세요**: the wake clears nothing from the shell's line before it
types. Two cases can still leave text there:
- a quit key the agent never read before the node ended it; only after
`agent_sleep.exit_keys_unanswered`, and no measured run reached it;
- a terminal's answer to the agent's query arriving after it exited;
never seen in a run.
- **판단해 주세요**: after a node end, Herdr keeps the agent's terminal modes
for the shell; filed as with-hide/hide-private#320 (Herdr upstream
report needed).
- **판단해 주세요**: Windows has no real-Herdr sleep-and-wake test (cell in
`docs/INSTALL.md`).
- Codex CLI 0.165.0 never turns the keyboard protocol on there: its
crossterm fork (`openai-oss-forks/crossterm` at `ed1cdab3`) answers
`PushKeyboardEnhancementFlags` with an unsupported error on a Windows
console.
- So a quit press reaches PowerShell as Ctrl+C, never as `ESC[99;5u`.
The press decision is the same code, with unit tests in the Windows
lane.
- **fish 4.9.3 `agent_pane_busy`, a fixture fault**:
- fish 4 runs its man-page completion generator (bash, Python) in its
own foreground group for about 3 s after its first prompt, unless
`~/.cache/fish/generated_completions` exists; fish 3 checked
`~/.local/share/fish`.
- The test sent its first `agent.start` without the shell wait every
product start has, and Herdr refused. It now starts through
`start_within`, and the fixture makes both folders.
- A product start waits on that state for up to 30 s (`SHELL_WAIT`). The
generator runs only on a user's first fish start; how long it takes over
a full set of man pages is not measured.
- **조심해서 볼 파일**:
- `herdr-core/src/agent_sleep_herdr.rs` - failure path: quit presses
follow the screen and the foreground group.
- `herdr-core/src/delivery/doorbell.rs` - failure path: only a failure
before `agent.prompt` retries on the timer.
- `scripts/agent_journey/cells.py`, `journey.py` - only a `NO_ANSWER`
verdict asks the provider log, and a start prefers any other failure.
- `herdr-core/src/agent_start/real_herdr_tests.rs` - the stand-in's
release (`Release`, `Watched`).
- **비용 검토**: sleep reads the screen every 100 ms while quitting, inside
its 5 s grace.

## Evidence

- **확인한 것**:
- Real Herdr 0.9.5: a stand-in Codex CLI (kitty keyboard on, quits on
the first Ctrl+C) is slept and woken by Hide.
- It hands its terminal back only when the test releases it: after the
sleep's screen read shows it quitting, or after a second press is
answered. No timer orders the steps.
- It reads its input a byte at a time up to the first whole Ctrl+C, so a
second press queued with the first stays for the shell.
- Old sleep: 10 of 10 fail (5 runs, zsh and bash), the wake running
`9;5ucodex resume slept-session`; also 10 of 10 when both presses are
queued before the stand-in reads (a local-only hold).
- New sleep: 15 of 15 pass (5 runs, zsh, bash and fish 4.9.3); Linux CI
runs zsh, bash and fish.
- Unit tests: a second press only on the agent's hint or an emptied
draft; an agent quitting on its first press gets one press.
- Unit test: a failed reservation rings again on the timer (0 bells
typed before the fix).
- Provider log: cursor boundary in the same second, another thread, a
later non-429 retry.
- Start composition: an emitter failure beside an unanswered turn and a
429 stays a failure (read `not measured` before the fix).
- Fake-model journey at 698b118, `codex` row alone (codex-cli
0.163.0): 12 of 12 cells; sleep ended Codex CLI by its own key (no
`exit_keys_unanswered`).
- **확인하지 못한 것**:
  - No real-Herdr sleep and wake on Windows (see Review).
- #307's original evidence was deleted; the cause was read from the
issue's log lines, not replayed.
  - No signed-in journey on Codex CLI 0.165.0 here, and no live 429.

<details><summary>Verification record</summary>

- base 047d094, head 2397a4e.
- CI run 40860922492 at 2397a4e, attempt 1: green, 41 pass, 3 skipping
(full run, `pr.yml` changed); `windows check` step "Agent sleep ends the
agent's process tree" 4 of 4, the three quit press tests included.
- CI run 40853614406 at f837d75, attempt 1: green, 21 pass, 10
skipping; `rust workspace` 5560 of 5560, real-Herdr shell step 10 of 10
(sleep and wake on zsh, bash and fish).
- CI run 40844861122 at 391c939: attempt 1 failed only `web e2e
windows`, in setup before any test (`spawnSync powershell.exe
ETIMEDOUT`); attempt 2 green, 21 pass, 10 skipping; `rust workspace`
5560 of 5560, real-Herdr shell step 10 of 10 (sleep and wake on zsh,
bash and fish).
- CI run 40839420249 at 698b118, attempt 1: green; `rust workspace`
5560 of 5560 tests, real-Herdr shell step 10 of 10.
- Local full `nextest -p herdr-core -p hide-agent-adapter`: not run
since 923c430 (3461 of 3461); the build at 698b118 hit a full disk,
and CI covers it.
- Python at 698b118: `test_agent_journey_provider_limit` and
`test_agent_journey_cells` 36 OK; `test_agent_live_protection` 53 OK
alone (it timed out in a full run while the disk filled).
- `fmt-check`, `clippy -p herdr-core --all-targets -D warnings` at
391c939: clean.
- Sleep and wake on real Herdr at f837d75: base sleep code 10 of 10
fail (zsh, bash, 5 runs each), and 10 of 10 with both presses queued
before the stand-in's first read; head 15 of 15 pass (zsh, bash, fish
4.9.3, 5 runs each). With that hold and 391c939's one-call read, the
base sleep passed 4 of 4, the hole the byte read closes.
- Sleep and wake on real Herdr at 391c939: base sleep code 10 of 10
fail (zsh, bash, 5 runs each); head 15 of 15 pass (zsh, bash, fish
4.9.3, 5 runs each); fish also passes with fish 4's marker folder
removed (7.4 s, the start waiting out the generator).
- Local fake-model journey, `codex` row, at 698b118: 12 of 12 pass.
- Review: letter-16881 addressed in 923c430 and ca3db1c;
letter-16914 in aed2c51 and 698b118; letter-16977 and letter-16979
in 391c939; letter-17055 in f837d75; the Windows lane runs the quit
press tests from 2397a4e.

</details>
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