delimit-cli 4.6.0 → 4.6.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.
@@ -1,107 +0,0 @@
1
- #!/bin/bash
2
- # LED-1259: Verify that the compiled license_core .so:
3
- # 1. Compiles cleanly from gateway/ai/license_core.py
4
- # 2. Imports successfully when the .py is absent
5
- # 3. Exposes all public functions/constants the shim relies on
6
- # 4. Returns correct validation verdicts for known-valid / known-expired
7
- # license dicts
8
- # 5. Contains zero bypass identifiers in `strings` output
9
- #
10
- # Runs in an isolated tmp dir so it doesn't pollute the bundle layout.
11
-
12
- set -euo pipefail
13
-
14
- SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
15
- NPM_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
16
- SRC="$NPM_ROOT/gateway/ai/license_core.py"
17
-
18
- if [ "$(uname -s)" != "Linux" ]; then
19
- echo "⏭️ test-license-core-so: non-Linux host — skipping (Linux-only first ship)"
20
- exit 0
21
- fi
22
-
23
- if [ ! -f "$SRC" ]; then
24
- echo "ℹ️ license_core.py not in bundle (already compiled or pre-build) — copying from gateway src for test"
25
- GW_SRC="${GATEWAY_OVERRIDE:-/home/delimit/delimit-gateway}/ai/license_core.py"
26
- if [ ! -f "$GW_SRC" ]; then
27
- echo "❌ No license_core.py source found (bundle or gateway). Cannot test."
28
- exit 1
29
- fi
30
- SRC="$GW_SRC"
31
- fi
32
-
33
- PY="${PYTHON:-python3}"
34
- TMP="$(mktemp -d)"
35
- trap 'rm -rf "$TMP"' EXIT
36
-
37
- echo "🧪 test-license-core-so: building in $TMP"
38
- mkdir -p "$TMP/ai"
39
- touch "$TMP/ai/__init__.py"
40
- cp "$SRC" "$TMP/license_core.py"
41
-
42
- cd "$TMP"
43
- "$PY" -m nuitka --module --quiet --remove-output --output-dir=. license_core.py 2>&1 | tail -3
44
-
45
- SO_FILE="$(ls -1 license_core.cpython-*-*.so 2>/dev/null | head -1)"
46
- if [ -z "$SO_FILE" ]; then
47
- echo "❌ Compile failed — no .so produced"
48
- exit 1
49
- fi
50
- echo " ✅ compiled: $SO_FILE ($(stat -c%s "$SO_FILE") bytes)"
51
-
52
- # Strings-grep for bypass identifiers
53
- HITS="$(strings "$SO_FILE" | grep -iE 'DELIMIT_TEST_MODE|DELIMIT_INTERNAL_LICENSE_KEY|JAMSONS' || true)"
54
- if [ -n "$HITS" ]; then
55
- echo "❌ Bypass identifiers leaked into .so:"
56
- echo "$HITS"
57
- exit 1
58
- fi
59
- echo " ✅ strings-grep clean"
60
-
61
- # Move .so under ai/, drop the .py, run import + behaviour checks
62
- mv "$SO_FILE" "ai/$SO_FILE"
63
- rm -f license_core.py
64
-
65
- "$PY" - <<'PY'
66
- import os, sys, time
67
- sys.path.insert(0, ".")
68
-
69
- # Import via the compiled .so only — no .py present
70
- from ai.license_core import (
71
- is_license_valid, revalidate_license, needs_revalidation,
72
- PRO_TOOLS, LICENSE_FILE, FREE_TRIAL_LIMITS, activate,
73
- load_license, check_premium, gate_tool,
74
- )
75
-
76
- assert isinstance(PRO_TOOLS, frozenset) and len(PRO_TOOLS) > 0, "PRO_TOOLS must be a non-empty frozenset"
77
- assert FREE_TRIAL_LIMITS.get("delimit_deliberate") == 3, "FREE_TRIAL_LIMITS missing delimit_deliberate=3"
78
- assert "delimit_deliberate" in PRO_TOOLS, "PRO_TOOLS must include delimit_deliberate"
79
- assert callable(activate), "activate must be callable"
80
- assert callable(revalidate_license), "revalidate_license must be callable"
81
-
82
- # Known-valid: pro tier, recent last_validated_at
83
- valid_recent = {"tier": "pro", "valid": True, "last_validated_at": time.time()}
84
- assert is_license_valid(valid_recent) is True, "recent pro license should be valid"
85
- assert needs_revalidation(valid_recent) is False, "recent pro license should not need revalidation"
86
-
87
- # Known-invalid: pro tier but last_validated_at > 44 days ago (beyond hard cutoff)
88
- expired = {"tier": "pro", "valid": True, "last_validated_at": time.time() - 60 * 86400}
89
- assert is_license_valid(expired) is False, "expired (60d) pro license must be invalid"
90
- assert needs_revalidation(expired) is True, "expired (60d) pro license must need revalidation"
91
-
92
- # Free tier never valid for Pro
93
- free = {"tier": "free", "valid": True}
94
- assert is_license_valid(free) is False, "free tier must not pass is_license_valid"
95
-
96
- # valid=False forces invalid even when timestamp is recent
97
- revoked = {"tier": "pro", "valid": False, "last_validated_at": time.time()}
98
- assert is_license_valid(revoked) is False, "revoked license must be invalid"
99
-
100
- # Legacy file with no timestamps — should signal needs_revalidation=True
101
- legacy = {"tier": "pro", "valid": True}
102
- assert needs_revalidation(legacy) is True, "legacy license without timestamps must need revalidation"
103
-
104
- print("ALL_OK")
105
- PY
106
-
107
- echo "✅ test-license-core-so: all checks passed"