Skip to content

test(quota-tracker): structural tests for read-quota.py path fix (#1055) - #1158

Closed
bassilkhilo-ag2 wants to merge 1 commit into
sonichi:mainfrom
bassilkhilo-ag2:test/quota-path-fix-1055
Closed

bassilkhilo-ag2 wants to merge 1 commit into
sonichi:mainfrom
bassilkhilo-ag2:test/quota-path-fix-1055

Conversation

@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator

What

Structural tests covering the _REPO_ROOT path-depth fix from PR #1055.

Background

Before #1055, read-quota.py used three .parent calls to walk from the script's resolved path up to the repo root. Through the ~/.claude/skills symlink the script resolves to <repo>/skills/quota-tracker/scripts/read-quota.py — four levels deep. Three .parent calls landed on <repo>/skills/, which has no src/ subdirectory. The from workspace_default import status_read_path import silently failed (hit the except Exception swallow), so quota was always reported as "not found" regardless of whether the credential proxy had written a fresh quota-state.json.

Tests (13 assertions)

# Assertion
1 _REPO_ROOT uses exactly four .parent calls
2 Three .parent calls (the old bug) must NOT be the final depth
3 _REPO_ROOT is joined with "src" for sys.path.insert
4 sys.path.insert(0, ...) used (not .append)
5 workspace_default imported (status_read_path)
6 status_read_path("quota-state.json") called
7 No Path.cwd() fallback (stale-shadow path removed)
8 No skills/quota-tracker Path construct for quota file
9 sys.exit(1) on missing quota file
10 Informative message printed before exit
11 Human-readable output shows remaining %
12 --json flag exists
13 --gate flag exists

Run

python3 tests/quota-path-fix.test.py

🤖 Generated with Claude Code

@VasiliyRad VasiliyRad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two issues before this can merge:

  1. build_log.md does not belong here. This is 114 lines of unrelated workspace state (passes 207–214: content posts, cross-node-sync, watch-tasks orphan fix, etc.). Drop the file from the PR.

  2. src/health-check.py is a production code change in a test-only PR. The _pid_script helper + multi-PID path-enriched warn is a real functional change — it deserves its own PR (or at least accurate title/description). The PR title says "structural tests for read-quota.py path fix" but ships a health-check behavior change undocumented in the description.

Minor: tests/quota-path-fix.test.py line 130 has import re as _re — re is already imported at the top of the file.

The quota-path-fix tests themselves look good — solid regression guard for the four-.parent depth fix.

@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator Author

Status update (2026-05-26): The build_log.md and src/health-check.py entries in this diff are a housekeeping artifact — local main has 3 commits ahead of upstream main (two build_log.md chore commits + the health-check multi-PID fix from d9a384c), and this branch was branched from local main before the divergence was noticed.

The health-check change ships cleanly in PR #1157 (already APPROVED by @VasiliyRad). The build_log.md chore commits should never have been pushed and will be dropped.

A rebase onto upstream main (dropping build_log.md, letting health-check land via #1157) is ready — pending owner go-ahead to force-push. The actual test content here is unchanged and passes against current main.

…onichi#1055)

Verifies the four-.parent fix so _REPO_ROOT / "src" correctly resolves
to the repo's src/ dir (where workspace_default.py lives). The old three-
.parent path landed on skills/ — causing silent import failure and quota
always reading as missing.

13 assertions: parent depth, no cwd fallback, status_read_path call,
--json/--gate flags, graceful exit on missing file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bassilkhilo-ag2
bassilkhilo-ag2 force-pushed the test/quota-path-fix-1055 branch from 4effb52 to b41b391 Compare May 27, 2026 02:58
@bassilkhilo-ag2

Copy link
Copy Markdown
Collaborator Author

Branch rebased onto origin/main — bundled junk (build_log.md, health-check.py, health-check-bridge-multi-pid.test.py) stripped. Diff is now clean: only the intended test file(s).

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