gitvow 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gitvow-0.2.1/src/gitvow.egg-info → gitvow-0.2.2}/PKG-INFO +1 -1
- {gitvow-0.2.1 → gitvow-0.2.2}/pyproject.toml +1 -1
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/hooks/__init__.py +8 -1
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/install.py +3 -1
- {gitvow-0.2.1 → gitvow-0.2.2/src/gitvow.egg-info}/PKG-INFO +1 -1
- {gitvow-0.2.1 → gitvow-0.2.2}/tests/test_hooks.py +26 -3
- {gitvow-0.2.1 → gitvow-0.2.2}/LICENSE +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/README.md +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/setup.cfg +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/__init__.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/__main__.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/cli.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/collect.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/default_policy.json +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/policy.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/redact.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/selftest.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/state.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow/transcript.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow.egg-info/SOURCES.txt +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow.egg-info/dependency_links.txt +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow.egg-info/entry_points.txt +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow.egg-info/requires.txt +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/src/gitvow.egg-info/top_level.txt +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/tests/test_collect.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/tests/test_install_cli.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/tests/test_packaging.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/tests/test_policy.py +0 -0
- {gitvow-0.2.1 → gitvow-0.2.2}/tests/test_redact.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitvow
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Provenance and policy gate for AI-agent coding sessions: session trailers on commits, redacted session notes in git, a tool-call gate, and a local ledger. No runtime dependencies.
|
|
5
5
|
Author-email: Nikhil Bora <nikhil@wirevow.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gitvow"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
description = "Provenance and policy gate for AI-agent coding sessions: session trailers on commits, redacted session notes in git, a tool-call gate, and a local ledger. No runtime dependencies."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "Apache-2.0"}
|
|
@@ -75,6 +75,7 @@ def pre_tool_use(h: dict[str, Any], home: str | None = None) -> tuple[int, str]:
|
|
|
75
75
|
st["session_id"] = h.get("session_id") or st.get("session_id")
|
|
76
76
|
st["transcript_path"] = h.get("transcript_path") or st.get("transcript_path")
|
|
77
77
|
st["steps"] = st.get("steps", 0) + 1
|
|
78
|
+
st["pending_commit"] = time.time() # the git hook adds trailers only while this is fresh
|
|
78
79
|
save_state(cwd, st)
|
|
79
80
|
if rules is None:
|
|
80
81
|
log_event(cwd, "allowed", {"tool": tool})
|
|
@@ -162,14 +163,20 @@ def post_tool_use(h: dict[str, Any], home: str | None = None) -> tuple[int, str]
|
|
|
162
163
|
return 0, ""
|
|
163
164
|
if tool != "Bash" or not COMMIT_RE.search(inp.get("command", "")):
|
|
164
165
|
return 0, ""
|
|
166
|
+
st = load_state(cwd)
|
|
167
|
+
if "pending_commit" in st:
|
|
168
|
+
del st["pending_commit"]
|
|
169
|
+
save_state(cwd, st)
|
|
165
170
|
rc, head, _ = git(["rev-parse", "HEAD"], cwd)
|
|
166
171
|
if rc != 0:
|
|
167
172
|
return 0, ""
|
|
168
173
|
rules, warn = _rules_or_none(cwd, home)
|
|
169
174
|
if rules is None:
|
|
170
175
|
return 0, warn
|
|
171
|
-
st = load_state(cwd)
|
|
172
176
|
summ = summarize(h.get("transcript_path") or st.get("transcript_path"), rules=rules)
|
|
177
|
+
_, head_msg, _ = git(["log", "-1", "--format=%B", head], cwd)
|
|
178
|
+
if "Gitvow-Session:" not in head_msg:
|
|
179
|
+
return 0, "" # the commit did not go through (or was not the agent's): no note
|
|
173
180
|
_, files, _ = git(["show", "--stat", "--format=", head], cwd)
|
|
174
181
|
attribution = _attribution(cwd, head, st.get("agent_blobs", {}), summ["files_written"])
|
|
175
182
|
session_id = h.get("session_id") or st.get("session_id")
|
|
@@ -14,7 +14,9 @@ GIT_HOOK = """#!/bin/sh
|
|
|
14
14
|
# gitvow: append session trailers when a session is active in this repo; chain to the repo's own hook if present.
|
|
15
15
|
GD="$(git rev-parse --git-dir)"; STATE="$GD/gitvow-session.json"
|
|
16
16
|
if [ -f "$STATE" ]; then
|
|
17
|
-
|
|
17
|
+
# Trailers go only on commits the agent itself runs: the PreToolUse gate sets pending_commit when the
|
|
18
|
+
# agent invokes git commit and PostToolUse clears it. A human commit in a terminal gets no trailer.
|
|
19
|
+
SID=$(python3 -c "import json,time;s=json.load(open('$STATE'));p=s.get('pending_commit') or 0;print(s.get('session_id') or '' if time.time()-p<300 else '')" 2>/dev/null)
|
|
18
20
|
STEP=$(python3 -c "import json;print(json.load(open('$STATE')).get('steps') or 0)" 2>/dev/null)
|
|
19
21
|
if [ -n "$SID" ] && ! grep -q "^Gitvow-Session:" "$1"; then printf "\\nGitvow-Session: %s\\nGitvow-Step: %s\\n" "$SID" "$STEP" >> "$1"; fi
|
|
20
22
|
fi
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitvow
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Provenance and policy gate for AI-agent coding sessions: session trailers on commits, redacted session notes in git, a tool-call gate, and a local ledger. No runtime dependencies.
|
|
5
5
|
Author-email: Nikhil Bora <nikhil@wirevow.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import json
|
|
2
2
|
import os
|
|
3
|
+
import time
|
|
3
4
|
|
|
4
5
|
from gitvow.hooks import post_tool_use, pre_tool_use, session_start, stop
|
|
5
6
|
from gitvow.install import _write_git_hook
|
|
@@ -51,12 +52,32 @@ def test_commit_flow_trailer_note_and_attribution(repo, home, payload, transcrip
|
|
|
51
52
|
assert att["files"][0]["agent_wrote"] is True and "agent_blob" not in att["files"][0]
|
|
52
53
|
|
|
53
54
|
|
|
54
|
-
def test_human_commit_has_no_trailer(repo, home):
|
|
55
|
+
def test_human_commit_has_no_trailer(repo, home, payload):
|
|
55
56
|
_write_git_hook(str(repo / ".gitvow" / "git-hooks"))
|
|
56
57
|
git(repo, "config", "core.hooksPath", ".gitvow/git-hooks")
|
|
57
58
|
(repo / "a.txt").write_text("h\n")
|
|
58
|
-
git(repo, "commit", "-qam", "human")
|
|
59
|
+
git(repo, "commit", "-qam", "human, no session at all")
|
|
59
60
|
assert "Gitvow-Session" not in git(repo, "log", "-1", "--format=%B")
|
|
61
|
+
session_start(payload("SessionStart"), str(home)) # session active, but the agent did not run git commit
|
|
62
|
+
(repo / "a.txt").write_text("h2\n")
|
|
63
|
+
git(repo, "commit", "-qam", "human, alongside a live session")
|
|
64
|
+
assert "Gitvow-Session" not in git(repo, "log", "-1", "--format=%B")
|
|
65
|
+
st = json.loads((repo / ".git" / "gitvow-session.json").read_text())
|
|
66
|
+
st["pending_commit"] = 1 # a stale flag from long ago
|
|
67
|
+
(repo / ".git" / "gitvow-session.json").write_text(json.dumps(st))
|
|
68
|
+
(repo / "a.txt").write_text("h3\n")
|
|
69
|
+
git(repo, "commit", "-qam", "human, stale flag")
|
|
70
|
+
assert "Gitvow-Session" not in git(repo, "log", "-1", "--format=%B")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_pending_flag_is_cleared_after_note_and_no_note_without_trailer(repo, home, payload):
|
|
74
|
+
session_start(payload("SessionStart"), str(home))
|
|
75
|
+
pre_tool_use(payload("PreToolUse", "Bash", {"command": "git commit -m x"}), str(home))
|
|
76
|
+
assert "pending_commit" in json.loads((repo / ".git" / "gitvow-session.json").read_text())
|
|
77
|
+
# the agent's commit failed (nothing to commit); PostToolUse still runs
|
|
78
|
+
code, msg = post_tool_use(payload("PostToolUse", "Bash", {"command": "git commit -m x"}), str(home))
|
|
79
|
+
assert (code, msg) == (0, "") and git(repo, "for-each-ref", "refs/notes/") == ""
|
|
80
|
+
assert "pending_commit" not in json.loads((repo / ".git" / "gitvow-session.json").read_text())
|
|
60
81
|
|
|
61
82
|
|
|
62
83
|
def test_git_hook_chains_to_repo_hook(repo, home):
|
|
@@ -65,7 +86,9 @@ def test_git_hook_chains_to_repo_hook(repo, home):
|
|
|
65
86
|
local = repo / ".git" / "hooks" / "prepare-commit-msg"
|
|
66
87
|
local.write_text('#!/bin/sh\necho LOCAL >> "$1"\n')
|
|
67
88
|
os.chmod(local, 0o700)
|
|
68
|
-
(repo / ".git" / "gitvow-session.json").write_text(
|
|
89
|
+
(repo / ".git" / "gitvow-session.json").write_text(
|
|
90
|
+
json.dumps({"session_id": "s", "steps": 2, "pending_commit": time.time()})
|
|
91
|
+
)
|
|
69
92
|
(repo / "a.txt").write_text("c\n")
|
|
70
93
|
git(repo, "commit", "-qam", "chain")
|
|
71
94
|
body = git(repo, "log", "-1", "--format=%B")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|