Skip to content

gate.py: infrastructure vs internal_error can be inverted or a false outside-repo allow recorded #66

Open

Description

@urban233

Found by the correctness-tests-specialist reviewing PR #59 (non-blocking; PR merged with these recorded as follow-up).

Two related gaps, sharing one root cause: _repo_root (src/codev_workflow/gate.py:228) silently falls back to the handed cwd when git rev-parse fails, rather than signaling that the repository root is unknown.

1. internal_error vs infrastructure can be inverted.
_current_branch (gate.py:237-247) runs git with no try/except. When git is absent or hangs, the exception propagates to check()'s except-all, which (as of PR #59) labels it internal_error -- the defect classification -- rather than infrastructure. _repo_root two lines away already catches (OSError, subprocess.TimeoutExpired) for the same condition. Reproduced: with git unresolvable, codev gate check --gate plan records {"decision": "degraded", "failure_class": "internal_error", "reason": "internal error: [Errno 2] No such file or directory: 'git'"}.

2. A subdirectory cwd plus broken git produces a false allow / outside-repo.
When git rev-parse fails and cwd is a subdirectory, _repo_root returns that subdirectory as if it were the repo root. Every path above it (including a genuinely in-repo pyproject.toml) then resolves to outside-repo via _plan_gate's docs/outside-repo branch (gate.py:529-534) -- a confidently recorded allow where the gate previously (correctly) recorded degraded. Not a new permission hole (the call was allowed either way), but it converts an honest non-answer into a false positive that would look clean in a health report.

Fix: either have _current_branch catch (OSError, subprocess.TimeoutExpired) like _repo_root does, or have check()'s except-all classify those two exception types as infrastructure; and only let _plan_gate claim outside-repo when the root was actually determined by git, not the raw fallback cwd.

Not urgent: failure_class is currently write-only (health.py does not yet split reporting on it), so neither gap is user-visible today.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions