Skip to content

Read a nested worktree, a device's first tab and a late acknowledgment as the folder a created tab was born for - #573

Merged
yansfil merged 4 commits into
mainfrom
fix/birth-cwd-cases
Oct 6, 2026
Merged

yansfil merged 4 commits into
mainfrom
fix/birth-cwd-cases

Conversation

@yansfil

@yansfil yansfil commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes #461
Related: follows #449 and #420

Summary

A new pane reports the cwd its shell was born in until it enters the start folder, and #449 made every reader see the folder a Hide-created tab was created for until then.
This goes through the cases #449 left out of scope: each has a core test that fixes the expected behavior, and where the behavior was wrong it is fixed.

Case from #461 Wrong today? Result
Birth cwd inside a linked worktree nested below the checkout Yes: counted as inside the outer checkout, so the clamp ended at once A folder in another worktree of the checkout's own repository is not the outer checkout's; the tab stays clamped until a pane reports the checkout proper
A device's first tab of a worktree it created Yes: not recorded, so it sat under the birth cwd's project Recorded from the device's worktree.create answer, like a local one
Device paths compared with local file system rules Yes: a link on this machine made a device's sibling folder look like the checkout Compared by names (hide_platform::path::wire_relative)
Device acknowledgment after the session carried the tab Yes: waited for the device's next publish The stored session is clamped for the new record and regrouped at once
Herdr path spelling No Probed against the pinned 0.9.1: a link plus trailing / is answered resolved, no separator; the comparison reads both sides as the folder, test pins both directions
30 s window on SystemTime Fragile: a wall-clock step ends it early Monotonic birth_clock, injected in tests; no wall-clock wait

Review

  • 판단해 주세요: known limit, documented in docs/ARCHITECTURE.md: a tab born inside a nested worktree before the catalog has listed it settles at once and the latch is not undone when the list arrives, because a settled record must not hide a later cd.
  • 판단해 주세요: a device checkout recorded through a link the device resolves does not settle by path (names only), so it is believed when the 30 s window ends and logged as created_tab.cwd_unsettled. I took that over the local-file-system false positives.
  • 조심해서 볼 파일:
    • herdr-core/src/runtime/session.rs - runtime mutex: the checkout is read once when the tab is recorded and the catalog's worktrees once when the catalog arrives (local_worktree_paths); a session reads each pane cwd once and compares nested worktrees by names, so there is no lookup per nested worktree. A device acknowledgment calls refresh_device_catalog once when the session already has the tab.
    • herdr-core/src/session_sync/coordinator.rs - high-frequency path: only the filter type changed.
    • herdr-core/src/runtime/agents.rs is untouched; the device acknowledgment path goes through record_created_device_tab.
  • 비용 검토: per session, clamps are built once and cost string comparisons over the owning repository's worktrees for at most 64 unsettled records, plus one file system read per pane and agent cwd of those tabs (two before). The catalog arrival reads each worktree path once. No new timers or threads.

Evidence

  • 확인한 것:
    • 8 new or rewritten core tests in runtime/tests/birth_cwd.rs and device_catalog.rs. On current main, 3 failed (nested worktree, device first tab, late acknowledgment); the device-path, second-acknowledgment and device-nested tests were then made to fail without their fix by mutation (clamp disabled, one record, empty nested list), and pass with it.
    • Herdr spelling measured on a private pinned Herdr server with an isolated HOME and socket: workspace.create and tab.create with <link>/proj/ answered the resolved path without the trailing /.
    • scripts/verify-cargo.sh test-scoped -p herdr-core: 1454 passed; clippy -p herdr-core --all-targets -D warnings and fmt-check clean; workstation-identity and harness-anchor checks pass.
    • One code-review subagent and the lead's review: fixed a second acknowledgment settling the first tab, lookups per nested worktree under the lock, a link-spelled checkout missing its nested worktrees, other repositories counted as nested, device paths rewritten with this machine's rules, a repeated acknowledgment restarting a record, and the device window settling a tab with no pane; two weak tests were strengthened and the tests for the rest fail under a mutation of their fix.
  • 확인하지 못한 것:
    • No native, Linux or Windows run, and no live device; device paths are covered by the core fixture and a table test of Windows-style spellings only.
    • What a Windows or differently cased device Herdr emits for a cwd was not observed; names compare exactly.
    • Whether refresh_device_catalog after an acknowledgment drops the request overlay ingest_remote_session lays (lay_remote_requests) was not checked; other callers share the pattern.

A folder in a linked worktree nested below the checkout is not the
checkout's own start folder, a device's first worktree tab is recorded like
a local one, device paths are compared by their names instead of this
machine's files, a device acknowledgment after the session carried the tab
regroups it at once, and the 30 s window runs on an injectable monotonic
clock.
…nt regroups the session

The stored device session already reads the other recorded tabs as their
folder, so the new record alone reads it. Nested worktrees are related by
names so no file system lookup runs under the runtime lock, and the device
nested-worktree and spelling cases are pinned by tests that fail without
their fix.
The checkout is read when the tab is recorded and the catalog's worktrees
when it arrives, so a session costs one read per pane cwd under the lock and
the nested list no longer scales it. Only the checkout's own repository's
worktrees count as nested, a device's paths are compared as the device wrote
them, a repeated acknowledgment keeps its record, a device tab with no pane
is not settled by the window, and the clamps are built once per ingest.
@yansfil
yansfil merged commit 40c1469 into main Oct 6, 2026
65 of 79 checks passed
@yansfil
yansfil deleted the fix/birth-cwd-cases branch October 6, 2026 00:54
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.

Hide가 만든 탭의 출생 cwd: #449가 남긴 경우들(중첩 worktree, 기기 첫 탭, 정착 창)

1 participant