Implement GitWorkspaceState classifier and Git probe severity discipline#41
Draft
Implement GitWorkspaceState classifier and Git probe severity discipline#41
Conversation
Agent-Logs-Url: https://github.com/SourceOS-Linux/agent-term/sessions/8903e044-50e6-445b-90ab-b6823fbf6fe9 Co-authored-by: mdheller <21163552+mdheller@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement GitWorkspaceState classifier and Git probe severity discipline
Implement GitWorkspaceState classifier and Git probe severity discipline
May 6, 2026
Contributor
Review: good classifier foundation, but not contract-complete yetThis PR has a strong start: typed state enum, severity discipline, caching/debounce, status-line output, and broad tests. CI is also reported successful on the PR head. However, before this should be marked ready/merged, it needs to align directly with the merged upstream contract from Required remediation:
Recommendation: keep the classifier as the implementation core, then add a thin adapter such as |
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.
Terminal/workspace watchers were probing non-repo directories,
.gitdirs, detached/bare/corrupt repos, and superseded watcher states without typed classification, producing warning spam for expected negative conditions.New module:
src/agent_term/git_workspace.pyGitWorkspaceStateenum — ten typed states:not_a_repo,repo_root,inside_worktree,inside_git_dir,bare_repo,worktree_no_remote,detached_head,corrupt_repo,permission_denied,operation_supersededseverity_for_state()— severity-discipline table; expected negative states (not_a_repo,inside_git_dir,bare_repo,worktree_no_remote,detached_head) areinfoby default;operation_supersededisdebug;corrupt_repo/permission_deniedarewarning; severity escalates towarningonly when the caller signals the pending op actually requires the missing capabilityclassify_git_workspace(path, *, force=False)— runsgit rev-parsesub-commands, detects.gitdir probing before any branch commands, catchesPermissionErrorfrom bothos.listdirand git stderr, detects corrupt repos from stderr keywords; results cached by resolved absolute path (force=Truebypasses cache)GitWorkspaceClassificationdataclass — carries state, path, branch, remote_status, severity, action_hint;to_status_line()renders the compact terminal UX format;to_metadata()emits adapter-ready dictTests:
tests/test_git_workspace.py27 tests covering every state, cache/debounce behaviour, severity-discipline invariants, status-line format, and metadata shape. All git I/O faked via
unittest.mock.patchon_run_git.