fix(B-0557): truly cwd-independent — import.meta.dir fallback#3821
Merged
AceHack merged 2 commits intoMay 16, 2026
Merged
Conversation
…audit-backlog triaged) Co-Authored-By: Claude <noreply@anthropic.com>
…tside git repo The slice 3 implementation (chdir via git rev-parse) only handled 'invoked from a subdir of the repo'. Running from /tmp (no git repo) fell through to process.cwd() = /tmp and produced empty results. Fix per Copilot finding on PR #3819: derive repo root from import.meta.dir when git rev-parse fails. The tool lives at <repo>/tools/hygiene/X.ts so resolve two levels up to reach repo root. Smoke test from /tmp now produces the same 33+ candidate output as running from repo root. 20/20 existing tests still pass (no regression). Resolves the acceptance bullet 'cd /tmp && bun /path/to/...' fully. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR completes B-0557 slice 3’s “cwd-independence” guarantee for tools/hygiene/audit-backlog-status-drift.ts by making repo-root detection work even when invoked from outside any git worktree (e.g., /tmp), ensuring backlog-relative reads and existsSync checks remain correct.
Changes:
- Update
detectRepoRoot()to prefergit rev-parse --show-toplevel, but when that fails, fall back to deriving the repo root from the script’s own location viaimport.meta.dir. - Add a hygiene-history tick log entry documenting the related audit/close activity.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/hygiene/audit-backlog-status-drift.ts | Make repo-root detection robust when executed outside a git repo by falling back to resolve(import.meta.dir, "../.."). |
| docs/hygiene-history/ticks/2026/05/16/0758Z.md | Add tick log entry for the session/audit context. |
AceHack
added a commit
that referenced
this pull request
May 16, 2026
…frastructure-eats-itself closure (#3825) Documents the complete 2026-05-16 session arc: - 6-layer infrastructure (memory x 2, rule, audit tool with 4 quality slices, B-0553 + B-0557 rows) - 9+ drift catches across Otto-CLI + Otto-Desktop surfaces (cross-surface convergence) - 7 PRs absorbed review-cycle findings; zero iteration treadmills - B-0557 itself flagged by its own audit tool → closed via PR #3819 - PR #3821 shipped truly-cwd-independent fallback (import.meta.dir) - ~30 PRs merged total Captures 9 operational patterns proven under multi-Otto + Lior contention (atomic Edit-Bash, HEAD:branch explicit push refspec, section-aware parsing, INLINE_CROSSREF, mixed-bullet handling, partial-vs-drift discriminator, etc.). memory/MEMORY.md reindex picked up the new entry. Co-authored-by: Claude <noreply@anthropic.com>
This was referenced May 16, 2026
This was referenced May 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git rev-parse --show-toplevelfrom /tmp fails (no git repo), and my fallback toprocess.cwd()returned /tmp which has no backlog.git rev-parsefails, fall back topath.resolve(import.meta.dir, "../.."). The tool lives at<repo>/tools/hygiene/X.tsso two levels up reaches the repo root regardless of cwd.Verification
Smoke from /tmp (the original failing case):
Test plan
bun test→ 20 pass / 0 fail / 40 expect calls (no regression)git rev-parsestill preferred when available (subdir-of-repo case)Unblocks PR #3819
Once this PR lands, PR #3819 (B-0557 close-row) can resolve its outstanding thread — slice 3's acceptance is now fully shipped, not partial.
🤖 Generated with Claude Code