Skip to content

fix(B-0557): truly cwd-independent — import.meta.dir fallback#3821

Merged
AceHack merged 2 commits into
mainfrom
fix/b0557-detect-repo-root-import-meta-fallback-otto-cli-2026-05-16
May 16, 2026
Merged

fix(B-0557): truly cwd-independent — import.meta.dir fallback#3821
AceHack merged 2 commits into
mainfrom
fix/b0557-detect-repo-root-import-meta-fallback-otto-cli-2026-05-16

Conversation

@AceHack
Copy link
Copy Markdown
Member

@AceHack AceHack commented May 16, 2026

Summary

  • Closes the scope gap that Copilot flagged on PR #3819: slice 3's cwd-independence acceptance bullet (`cd /tmp && bun /path/to/...`) was only partially shipped — git rev-parse --show-toplevel from /tmp fails (no git repo), and my fallback to process.cwd() returned /tmp which has no backlog.
  • Fix: when git rev-parse fails, fall back to path.resolve(import.meta.dir, "../.."). The tool lives at <repo>/tools/hygiene/X.ts so two levels up reaches the repo root regardless of cwd.

Verification

Smoke from /tmp (the original failing case):

$ cd /tmp && bun /path/to/tools/hygiene/audit-backlog-status-drift.ts --json | head -5
# Now produces the same 33+ candidate output as running from the repo root
# (was previously empty `[]`).

Test plan

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

AceHack and others added 2 commits May 16, 2026 04:03
…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>
Copilot AI review requested due to automatic review settings May 16, 2026 08:07
@AceHack AceHack enabled auto-merge (squash) May 16, 2026 08:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 prefer git rev-parse --show-toplevel, but when that fails, fall back to deriving the repo root from the script’s own location via import.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 AceHack merged commit 58350d9 into main May 16, 2026
33 checks passed
@AceHack AceHack deleted the fix/b0557-detect-repo-root-import-meta-fallback-otto-cli-2026-05-16 branch May 16, 2026 08:11
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>
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.

2 participants