Skip to content

test(context-guard, rate-limit-guard): mod tests fail on Windows because they hard-code a POSIX home (/srv/u) #11368

Closed

Description

@kyle-sexton

Problem

On Windows, scripts/validate-plugins.sh --only "harness-ops" fails on a clean origin/main (6d6939f): 15 of 151 mod tests fail. Since #11360 made the check-affected pre-push hook run on Windows, this blocks every Windows push that touches harness-ops.

(fail) zones.json: custom edges move the crossings, and a later edit takes effect at the next call
    test's fs.stat hook was skipped: test: ENOENT: D:\srv\u\.claude\context-guard\zones.json
...
 136 pass
 15 fail
Mod tests failed.

Cause (UNVERIFIED in detail)

plugins/context-guard/hooks/context-guard.test.ts:10-12 sets HOME = '/srv/u' and keys its fake files by POSIX paths such as /srv/u/.claude/context-guard/zones.json. On Windows the mod resolves that home to D:\srv\u\..., so the test's fake fs.stat never matches and the run reads the real disk. plugins/rate-limit-guard/hooks/rate-limit-guard.test.ts uses the same pattern (the ENOENT on D:\srv\u\.claude.json). CI runs on ubuntu-24.04, so CI stays green.

Fix direction

Build the fake home and its file keys with the platform's path rules (for example path.resolve('/srv/u') and path.join), and compare expected text through the same helper, so the tests pass on Windows and Linux.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UJUn7KoThXoYQoxfvdCVi7

Activity

  1. added
    needs-triageNot yet classified. Floor until a type and one priority tier are set.
    on Oct 30, 2026
  2. github-actions commented on Oct 30, 2026

    @github-actions
    Contributor

    Proposed work class: work-class: scoped
    Basis: automated intake triage; the lanes App applied this class.

    Size: Small
    Complexity: Low
    Uncertainty: Known
    Flags: none
    Blocked by: none

    Understood: the context-guard and rate-limit-guard mod tests hard-code a POSIX home (/srv/u). On Windows the mods resolve it to D:\srv\u, so the fake fs never matches and 15 tests fail. The fix is to build the fake home and file keys with path.resolve and path.join, and to build the expected text from the same constants. The refinement comment already lists the acceptance criteria. I found no likely duplicates among the open issues.

    Automated triage, applied by the lanes App.

  3. added
    priority: mediumReal value, no hard deadline; normal backlog flow.
    and removed
    needs-triageNot yet classified. Floor until a type and one priority tier are set.
    on Oct 30, 2026
  4. added
    status: readyTriaged, unblocked, and fully specified; eligible to pick up.
    work-class: scopedA briefed fix or small feature; blast radius bounded by the brief, tests exist.
    status: confirmedA maintainer confirmed the item is real and in scope; ready to be worked.
    and removed
    status: readyTriaged, unblocked, and fully specified; eligible to pick up.
    on Oct 30, 2026
  5. melodic-automation-lanes commented on Oct 30, 2026

    @melodic-automation-lanes
    Contributor

    Not admitted to the issue lane yet: open pull request #11369 is for it.

  6. melodic-automation-lanes commented on Oct 30, 2026

    @melodic-automation-lanes
    Contributor

    The latest triage verdict holds nothing: the issue is at status: ready.

  7. added
    needs-triageNot yet classified. Floor until a type and one priority tier are set.
    and removed
    status: confirmedA maintainer confirmed the item is real and in scope; ready to be worked.
    on Oct 30, 2026
  8. melodic-automation-lanes commented on Oct 30, 2026

    @melodic-automation-lanes
    Contributor

    Refinement. A read-only run explored this repository, searched its issues and pull requests, and read the allowed docs to draft what follows. On an issue a listed human filed, it counts as the issue's spec once posted, while unedited; it is still model text, so check it.

    Intended outcome: Both guard test files build the fake home, file keys and expected path text with node:path (resolve/join) so the mod tests pass on Windows and Linux.

    Acceptance criteria

    • plugins/context-guard/hooks/context-guard.test.ts defines HOME with path.resolve('/srv/u') and derives CTX and ZONES with path.join from HOME, with no literal '/srv/u/' string left
    • plugins/rate-limit-guard/hooks/rate-limit-guard.test.ts defines HOME with path.resolve('/srv/u') and derives TARGET and STATE_FILE with path.join from HOME, with no literal '/srv/u/' string left
    • The expected text at context-guard.test.ts:1305 and :1321 that names zones.json is built from the ZONES constant, not a POSIX literal
    • Other hard-coded POSIX keys in the two files that the mod resolves (such as CLAUDE_CONFIG_DIR '/cfg' at rate-limit-guard.test.ts:1057) go through path.resolve and path.join where the mod resolves them
    • The USERPROFILE-fallback tests in both files still pass and use the same helper-built home
    • scripts/validate-plugins.sh --only "harness-ops" passes on Linux with the same test count and no failures
    • No change to the mod sources under plugins/context-guard/hooks or plugins/rate-limit-guard/hooks other than the two .test.ts files

    External state: none

    Related work

    Sources read

    • plugins/context-guard/hooks/context-guard.test.ts:10-12: HOME='/srv/u', CTX and ZONES are POSIX literals
    • plugins/context-guard/hooks/context-guard.test.ts:1305: expected text hard-codes /srv/u/.claude/context-guard/zones.json
    • plugins/rate-limit-guard/hooks/rate-limit-guard.test.ts:13-15: HOME, TARGET, STATE_FILE are POSIX literals under /srv/u
    • plugins/rate-limit-guard/hooks/rate-limit-guard.test.ts:1057: CLAUDE_CONFIG_DIR '/cfg' is another POSIX literal

    Automated refinement by the lanes App. Intake triages the issue again with it.

  9. removed
    needs-triageNot yet classified. Floor until a type and one priority tier are set.
    on Oct 30, 2026
  10. added
    status: readyTriaged, unblocked, and fully specified; eligible to pick up.
    admission-deferredAdmitted but waiting for WIP room; the hourly work-unblock sweep labels it agent-ready.
    on Oct 30, 2026
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

    admission-deferredAdmitted but waiting for WIP room; the hourly work-unblock sweep labels it agent-ready.priority: mediumReal value, no hard deadline; normal backlog flow.status: readyTriaged, unblocked, and fully specified; eligible to pick up.work-class: scopedA briefed fix or small feature; blast radius bounded by the brief, tests exist.

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions