Skip to content

Nightly drift cleanup: doc banner, eval dry-run example, 32-bit codename, post-starts test typo #2663

Closed

Description

@worktrunk-bot

Findings from the nightly survey on 2026-05-10 — small drift items, none urgent.

1. Stale "edit cli.rs to update" banner in auto-generated docs

src/help.rs:125 emits <\!-- ⚠️ AUTO-GENERATED from \wt {subcommand} --help-page` — edit cli.rs to update -->into every command page and skill reference. The actual source issrc/cli/mod.rs(nocli.rsexists at the crate root). Banner appears indocs/content/{config,hook,list,merge,remove,step,switch}.mdand the matchingskills/worktrunk/reference/*.md` files.

Fix: change cli.rs to src/cli/mod.rs in src/help.rs:125, then cargo test --test integration test_docs_are_in_sync to propagate.

2. wt step eval --dry-run example shows ... instead of ---

src/cli/step.rs:430-438 documents the dry-run output as:

$ wt step eval --dry-run '{{ branch }}'
branch=feature/auth-oauth2
worktree_path=/home/user/projects/myapp-feature-auth-oauth2
...
Result: feature/auth-oauth2

But src/commands/eval.rs:44 actually emits a --- separator (eprintln\!("---")) before Result: …. Update the doc to match. Requires cargo insta test --accept -- --test integration "test_help" to refresh tests__help__help_step_long.snap.

3. codename_index 32-bit truncation

src/config/expansion.rs:485-499 claims the hash is "identical across 32-bit and 64-bit builds," but the final expression is:

(u64::from_le_bytes(bytes) as usize) % len

On 32-bit, the as usize cast truncates the upper 32 bits before the modulo, producing different word indices than on 64-bit. Worktrunk doesn't ship 32-bit binaries today, so the practical impact is zero, but the comment is misleading.

Fix: (u64::from_le_bytes(bytes) % len as u64) as usize. No test changes required (identical on 64-bit).

4. Switch tests use invalid post-starts = config key

tests/integration_tests/switch.rs:791 and :847 write project config:

post-starts = ["echo 'marker' > marker.txt"]

The valid key is post-start (singular, matched in src/config/hooks.rs:42). Both tests assert that --no-hooks skips the post-start hook, but with this typo the hook is never registered — the snapshot would match even without --no-hooks. The tests pass for the wrong reason.

Fix:

  • Change post-starts = [...] to post-start = "..." in both tests.
  • Add a marker-file assertion (e.g., assert\!(\!repo.root_path().join("marker.txt").exists())) so the test actually verifies the skip.
  • Re-run cargo insta test --accept -- --test integration switch_no_hooks_skips_post_start switch_no_hooks_with_yes to refresh snapshots if any unknown-field warning fires.

5. Other low-priority drift (skip unless you want a sweep)

  • src/copy.rs:213-218 uses anyhow::ensure\!(e.kind() == ErrorKind::NotFound, e) to bail — if e.kind() \!= ErrorKind::NotFound { return Err(e.into()); } reads cleaner.
  • src/output/shell_integration.rs:215-228 and :264-267 return anyhow::Result<()> despite never erroring — drop the Result.
  • src/git/repository/working_tree.rs:331-345: is_dirty() and dirty_files() both shell out to git status --porcelain. is_dirty() could be Ok(\!self.dirty_files()?.is_empty()).
  • src/styling/mod.rs:34: #[cfg(all(test, feature = "syntax-highlighting"))] pub(crate) use ... is test-only library code — move to test module per CLAUDE.md "No Test Code in Library Code."
  • tests/integration_tests/custom.rs:122-139: hand-rolled strip_ansi duplicates ansi_str::AnsiStr::ansi_strip() (already a transitive dep via src/styling/mod.rs).
  • tests/integration_tests/custom.rs:170-201: custom_subcommand_respects_global_dash_c_flag admits the assertion is "indirect" — would pass even if -C were silently dropped. Strengthen or delete.

Activity

  1. added
    nightly-cleanup
    on May 10, 2026
  2. worktrunk-bot commented on May 10, 2026

    @worktrunk-bot
    CollaboratorAuthor

    Took item 4 (the post-starts = test typo) since it was the only finding with a real correctness consequence — the snapshot was passing even though the post-start hook never registered. Fix is in #2664: corrected the TOML key, added a marker-file assertion in the new worktree, and confirmed the assertion is meaningful by removing --no-hooks and watching the snapshot diverge.

    Items 1 (stale edit cli.rs banner in src/help.rs:125), 2 (... vs --- in the wt step eval --dry-run example), and 3 (codename_index 32-bit truncation comment) are independent and well-scoped — left for separate PRs to keep them atomic.

  3. max-sixty commented on May 10, 2026

    @max-sixty
    Owner

    fix any others that would make the code better

  4. worktrunk-bot commented on May 10, 2026

    @worktrunk-bot
    CollaboratorAuthor

    Six follow-up PRs, one concern each, against the items above:

    Skipped from item 5:

    • src/copy.rs:213-218 (anyhow::ensure! shape) — purely stylistic; current code is correct, refactor adds no value.
    • src/git/repository/working_tree.rs:331-345 (is_dirty() calling dirty_files()) — would allocate a Vec<String> on every clean check just for a boolean. Performance regression, not a cleanup.
    • tests/integration_tests/custom.rs:170-201 (weak -C assertion) — making it actually verify cwd needs the mock-stub binary to grow a "report cwd" feature; it's scope creep for an annotation that's already honest about the limitation.

    Happy to revisit any of those three if you'd rather have them.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    nightly-cleanup

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions