@miller-tech/uap 1.67.0 → 1.67.1
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.
package/package.json
CHANGED
|
Binary file
|
|
@@ -37,9 +37,16 @@ SOURCE_EXTS = (
|
|
|
37
37
|
".c", ".cc", ".cpp", ".h", ".hpp",
|
|
38
38
|
)
|
|
39
39
|
|
|
40
|
+
# NOTE: `.worktrees/` is deliberately NOT exempt here. A real `uap deliver` run
|
|
41
|
+
# writes into a worktree but sets UAP_DELIVER_ACTIVE=1, which is honored below —
|
|
42
|
+
# so legitimate deliver edits still pass. An unconditional `.worktrees/` exemption
|
|
43
|
+
# let the model BYPASS deliver entirely by creating a worktree dir and writing
|
|
44
|
+
# source straight into it (observed: 24 source files written to
|
|
45
|
+
# .worktrees/001-space-shooter/ with no deliver run). Gating it behind the active
|
|
46
|
+
# flag closes that hole.
|
|
40
47
|
EXEMPT_PREFIXES = (
|
|
41
48
|
".claude/", ".cursor/", ".opencode/", ".codex/", ".forge/", ".omp/",
|
|
42
|
-
".uap/", ".policy-tools/",
|
|
49
|
+
".uap/", ".policy-tools/",
|
|
43
50
|
"src/policies/", "scripts/", "docs/", "policies/", "test/", "tests/",
|
|
44
51
|
)
|
|
45
52
|
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""delivery-enforcement must NOT let a `.worktrees/` path bypass the deliver
|
|
3
|
+
pipeline. A real `uap deliver` run writes into a worktree but sets
|
|
4
|
+
UAP_DELIVER_ACTIVE=1 (honored), so legitimate deliver edits still pass; an
|
|
5
|
+
unconditional `.worktrees/` exemption let the model sidestep deliver by writing
|
|
6
|
+
source straight into a worktree dir it created itself.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import importlib.util
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import subprocess
|
|
13
|
+
import sys
|
|
14
|
+
import unittest
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
ENF = (
|
|
18
|
+
Path(__file__).resolve().parents[3]
|
|
19
|
+
/ "src" / "policies" / "enforcers" / "delivery_enforcement.py"
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def run(path, root, env_extra=None):
|
|
24
|
+
env = dict(os.environ)
|
|
25
|
+
env["UAP_REPO_ROOT"] = str(root)
|
|
26
|
+
env["UAP_ENFORCE_DELIVERY"] = "block"
|
|
27
|
+
env.pop("UAP_DELIVER_ACTIVE", None)
|
|
28
|
+
env.pop("UAP_DELIVER_BYPASS", None)
|
|
29
|
+
if env_extra:
|
|
30
|
+
env.update(env_extra)
|
|
31
|
+
p = subprocess.run(
|
|
32
|
+
[sys.executable, str(ENF), "--operation", "Write",
|
|
33
|
+
"--args", json.dumps({"file_path": str(Path(root) / path)})],
|
|
34
|
+
capture_output=True, text=True, env=env,
|
|
35
|
+
)
|
|
36
|
+
try:
|
|
37
|
+
return json.loads(p.stdout)["allowed"]
|
|
38
|
+
except Exception:
|
|
39
|
+
return None
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class TestDeliveryEnforcementWorktree(unittest.TestCase):
|
|
43
|
+
def setUp(self):
|
|
44
|
+
import tempfile
|
|
45
|
+
self._t = tempfile.TemporaryDirectory()
|
|
46
|
+
self.root = self._t.name
|
|
47
|
+
|
|
48
|
+
def tearDown(self):
|
|
49
|
+
self._t.cleanup()
|
|
50
|
+
|
|
51
|
+
def test_worktree_source_write_blocked_without_deliver_run(self):
|
|
52
|
+
# the bypass: was ALLOWED, must now be BLOCKED
|
|
53
|
+
self.assertFalse(run(".worktrees/001-x/js/game.js", self.root))
|
|
54
|
+
|
|
55
|
+
def test_worktree_source_write_allowed_inside_deliver_run(self):
|
|
56
|
+
self.assertTrue(
|
|
57
|
+
run(".worktrees/001-x/js/game.js", self.root, {"UAP_DELIVER_ACTIVE": "1"})
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
def test_worktree_nonsource_still_allowed(self):
|
|
61
|
+
self.assertTrue(run(".worktrees/001-x/css/styles.css", self.root))
|
|
62
|
+
|
|
63
|
+
def test_direct_source_still_blocked(self):
|
|
64
|
+
self.assertFalse(run("src/game.js", self.root))
|
|
65
|
+
|
|
66
|
+
def test_other_exemptions_intact(self):
|
|
67
|
+
self.assertTrue(run(".uap/state.js", self.root))
|
|
68
|
+
self.assertTrue(run("scripts/build.js", self.root))
|
|
69
|
+
|
|
70
|
+
def test_bypass_override_still_works(self):
|
|
71
|
+
self.assertTrue(
|
|
72
|
+
run(".worktrees/001-x/js/game.js", self.root, {"UAP_DELIVER_BYPASS": "1"})
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
if __name__ == "__main__":
|
|
77
|
+
unittest.main()
|