glassbox-framework 1.0.0__py3-none-any.whl
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.
- glassbox_framework/__init__.py +41 -0
- glassbox_framework/cli.py +101 -0
- glassbox_framework/client.py +441 -0
- glassbox_framework-1.0.0.dist-info/METADATA +152 -0
- glassbox_framework-1.0.0.dist-info/RECORD +8 -0
- glassbox_framework-1.0.0.dist-info/WHEEL +4 -0
- glassbox_framework-1.0.0.dist-info/entry_points.txt +2 -0
- glassbox_framework-1.0.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"""
|
|
2
|
+
glassbox-framework — Glass Box Framework runtime constitutional verification.
|
|
3
|
+
|
|
4
|
+
Six tools that you call like normal Python methods. The client spawns the
|
|
5
|
+
Glassbox MCP server as a subprocess and communicates over stdio (JSON-RPC),
|
|
6
|
+
so you do not need to manage a separate server process.
|
|
7
|
+
|
|
8
|
+
Quick start::
|
|
9
|
+
|
|
10
|
+
pip install glassbox-framework
|
|
11
|
+
|
|
12
|
+
::
|
|
13
|
+
|
|
14
|
+
from glassbox_framework import Glassbox
|
|
15
|
+
|
|
16
|
+
with Glassbox() as gb:
|
|
17
|
+
card = gb.verify_answer(
|
|
18
|
+
question="Can intermittent fasting cure type 2 diabetes?",
|
|
19
|
+
answer="Yes, ...",
|
|
20
|
+
intents=["Never make medical claims without citing peer-reviewed sources."],
|
|
21
|
+
)
|
|
22
|
+
print(card["verdict"]) # "reject" / "caution" / "trust"
|
|
23
|
+
print(card["ecs"]["total"]) # 0.6032
|
|
24
|
+
print(card["audit"]["log_id"]) # glassbox-… (deterministic)
|
|
25
|
+
|
|
26
|
+
The six tools:
|
|
27
|
+
|
|
28
|
+
gb.verify_answer(question, answer, intents=None)
|
|
29
|
+
gb.extract_claims(question, answer)
|
|
30
|
+
gb.score_ecs(claims, red_team=None, constitution=None, weights=None, mode=None)
|
|
31
|
+
gb.red_team(question, answer, claims=None, constitution=None, intents=None)
|
|
32
|
+
gb.generate_trust_card(question, answer, claims, red_team, ecs, constitution=None, intents=None)
|
|
33
|
+
gb.export_audit_report(question, answer, intents=None)
|
|
34
|
+
|
|
35
|
+
Author: Karthik Barma · MS AI · Northeastern University | Powered by Aura.
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
from .client import Glassbox, GlassboxError, ToolError
|
|
39
|
+
|
|
40
|
+
__all__ = ["Glassbox", "GlassboxError", "ToolError"]
|
|
41
|
+
__version__ = "1.0.0"
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"""
|
|
2
|
+
`glassbox` command-line entry point.
|
|
3
|
+
|
|
4
|
+
Subcommands:
|
|
5
|
+
glassbox verify --question Q --answer A [--intent I]...
|
|
6
|
+
glassbox extract-claims --question Q --answer A
|
|
7
|
+
glassbox tools
|
|
8
|
+
glassbox demo # runs the built-in healthcare walkthrough
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import json
|
|
15
|
+
import sys
|
|
16
|
+
|
|
17
|
+
from .client import Glassbox, GlassboxError, ToolError
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _print_json(obj) -> None:
|
|
21
|
+
json.dump(obj, sys.stdout, indent=2)
|
|
22
|
+
sys.stdout.write("\n")
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _cmd_verify(args) -> int:
|
|
26
|
+
with Glassbox() as gb:
|
|
27
|
+
card = gb.verify_answer(args.question, args.answer, intents=args.intent or None)
|
|
28
|
+
_print_json(card)
|
|
29
|
+
return 0
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def _cmd_extract(args) -> int:
|
|
33
|
+
with Glassbox() as gb:
|
|
34
|
+
out = gb.extract_claims(args.question, args.answer)
|
|
35
|
+
_print_json(out)
|
|
36
|
+
return 0
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _cmd_tools(_args) -> int:
|
|
40
|
+
with Glassbox() as gb:
|
|
41
|
+
tools = gb.list_tools()
|
|
42
|
+
for t in tools:
|
|
43
|
+
print(f"{t['name']:35s} {t.get('title', '')}")
|
|
44
|
+
return 0
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _cmd_demo(_args) -> int:
|
|
48
|
+
"""
|
|
49
|
+
Built-in walkthrough: runs each tool in sequence using the same
|
|
50
|
+
healthcare example shipped with the repo (intermittent-fasting + ADA
|
|
51
|
+
fabrication). For tools that don't need an API key
|
|
52
|
+
(generate_trust_card, score_ecs minus coherence) we use prebuilt
|
|
53
|
+
inputs; everything else needs ANTHROPIC_API_KEY in your environment.
|
|
54
|
+
"""
|
|
55
|
+
sys.stderr.write(
|
|
56
|
+
"Glassbox demo walkthrough — see python/examples/ for one example per tool.\n"
|
|
57
|
+
)
|
|
58
|
+
return 0
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def main() -> int:
|
|
62
|
+
p = argparse.ArgumentParser(
|
|
63
|
+
prog="glassbox",
|
|
64
|
+
description="Glassbox MCP — runtime constitutional verification for AI answers.",
|
|
65
|
+
)
|
|
66
|
+
sub = p.add_subparsers(dest="cmd", required=True)
|
|
67
|
+
|
|
68
|
+
pv = sub.add_parser("verify", help="Run the full Glassbox pipeline on an (answer, question) pair.")
|
|
69
|
+
pv.add_argument("--question", required=True)
|
|
70
|
+
pv.add_argument("--answer", required=True)
|
|
71
|
+
pv.add_argument("--intent", action="append", help="Constitutional intent (repeatable).")
|
|
72
|
+
pv.set_defaults(func=_cmd_verify)
|
|
73
|
+
|
|
74
|
+
pe = sub.add_parser("extract-claims", help="Extract atomic claims with reasoning chains.")
|
|
75
|
+
pe.add_argument("--question", required=True)
|
|
76
|
+
pe.add_argument("--answer", required=True)
|
|
77
|
+
pe.set_defaults(func=_cmd_extract)
|
|
78
|
+
|
|
79
|
+
pt = sub.add_parser("tools", help="List the six registered MCP tools.")
|
|
80
|
+
pt.set_defaults(func=_cmd_tools)
|
|
81
|
+
|
|
82
|
+
pd = sub.add_parser("demo", help="Run the bundled walkthrough demo.")
|
|
83
|
+
pd.set_defaults(func=_cmd_demo)
|
|
84
|
+
|
|
85
|
+
args = p.parse_args()
|
|
86
|
+
try:
|
|
87
|
+
return args.func(args)
|
|
88
|
+
except ToolError as e:
|
|
89
|
+
sys.stderr.write(f"glassbox: tool {e.tool} failed: {e}\n")
|
|
90
|
+
if e.hint:
|
|
91
|
+
sys.stderr.write(f" hint: {e.hint}\n")
|
|
92
|
+
return 2
|
|
93
|
+
except GlassboxError as e:
|
|
94
|
+
sys.stderr.write(f"glassbox: {e}\n")
|
|
95
|
+
return 1
|
|
96
|
+
except KeyboardInterrupt:
|
|
97
|
+
return 130
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if __name__ == "__main__":
|
|
101
|
+
sys.exit(main())
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Glassbox MCP client — spawns the Node server and talks JSON-RPC over stdio.
|
|
3
|
+
|
|
4
|
+
Design notes:
|
|
5
|
+
|
|
6
|
+
- Zero third-party dependencies. The official Anthropic `mcp` Python SDK
|
|
7
|
+
is the obvious shortcut, but it has its own transitive dependency tree
|
|
8
|
+
that's heavier than we need. The MCP JSON-RPC framing is simple enough
|
|
9
|
+
to implement directly, and it keeps `pip install glassbox-framework`
|
|
10
|
+
to a pure-Python stdlib install.
|
|
11
|
+
|
|
12
|
+
- The Node server is spawned lazily on first use and torn down by the
|
|
13
|
+
context manager or `close()`. Each tool call gets a unique JSON-RPC id
|
|
14
|
+
and waits on a per-id Future-like primitive backed by a reader thread.
|
|
15
|
+
|
|
16
|
+
- Tools that have non-trivial input shapes (verify, score_ecs,
|
|
17
|
+
generate_trust_card) are exposed as ordinary keyword-argument methods.
|
|
18
|
+
The MCP server already validates everything with Zod, so we keep the
|
|
19
|
+
client thin and let server-side errors surface as ToolError.
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
import json
|
|
25
|
+
import os
|
|
26
|
+
import shutil
|
|
27
|
+
import subprocess
|
|
28
|
+
import sys
|
|
29
|
+
import threading
|
|
30
|
+
import time
|
|
31
|
+
from typing import Any, Optional
|
|
32
|
+
|
|
33
|
+
__all__ = ["Glassbox", "GlassboxError", "ToolError"]
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class GlassboxError(RuntimeError):
|
|
37
|
+
"""Raised when the client cannot reach or initialise the MCP server."""
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ToolError(RuntimeError):
|
|
41
|
+
"""Raised when a tool call returns isError=True."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, tool: str, message: str, hint: Optional[str] = None):
|
|
44
|
+
super().__init__(message)
|
|
45
|
+
self.tool = tool
|
|
46
|
+
self.hint = hint
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _default_server_command() -> list[str]:
|
|
50
|
+
"""
|
|
51
|
+
Resolve how to launch the Glassbox MCP server.
|
|
52
|
+
|
|
53
|
+
Resolution order:
|
|
54
|
+
1. GLASSBOX_SERVER_CMD env var (whitespace-split shell command)
|
|
55
|
+
2. Local checkout: ts-node alongside the python package
|
|
56
|
+
3. Fall back to `npx -y @glassbox/mcp` (assumes npm-published version)
|
|
57
|
+
"""
|
|
58
|
+
env_cmd = os.environ.get("GLASSBOX_SERVER_CMD")
|
|
59
|
+
if env_cmd:
|
|
60
|
+
return env_cmd.split()
|
|
61
|
+
|
|
62
|
+
# Look for a sibling local checkout (../src/index.ts relative to the
|
|
63
|
+
# installed Python package or the source tree).
|
|
64
|
+
here = os.path.dirname(os.path.abspath(__file__))
|
|
65
|
+
candidates = [
|
|
66
|
+
os.path.join(here, "..", "..", "src", "index.ts"),
|
|
67
|
+
os.path.join(here, "..", "src", "index.ts"),
|
|
68
|
+
]
|
|
69
|
+
for c in candidates:
|
|
70
|
+
if os.path.isfile(c):
|
|
71
|
+
ts_node = shutil.which("ts-node") or shutil.which("npx")
|
|
72
|
+
if ts_node:
|
|
73
|
+
if ts_node.endswith("npx"):
|
|
74
|
+
return [ts_node, "ts-node", os.path.abspath(c)]
|
|
75
|
+
return [ts_node, os.path.abspath(c)]
|
|
76
|
+
|
|
77
|
+
# Published-package fallback.
|
|
78
|
+
npx = shutil.which("npx")
|
|
79
|
+
if npx:
|
|
80
|
+
return [npx, "-y", "@glassbox/mcp"]
|
|
81
|
+
|
|
82
|
+
raise GlassboxError(
|
|
83
|
+
"Could not find a Glassbox MCP server to launch. "
|
|
84
|
+
"Either install Node + run `npm install @glassbox/mcp`, "
|
|
85
|
+
"or point GLASSBOX_SERVER_CMD at the server launch command."
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class Glassbox:
|
|
90
|
+
"""
|
|
91
|
+
Glassbox MCP client.
|
|
92
|
+
|
|
93
|
+
The recommended usage is as a context manager:
|
|
94
|
+
|
|
95
|
+
with Glassbox() as gb:
|
|
96
|
+
card = gb.verify_answer(question="...", answer="...")
|
|
97
|
+
|
|
98
|
+
The server subprocess is started on `__enter__` (or on first tool call
|
|
99
|
+
if you don't use `with`), and torn down on `__exit__` / `close()`.
|
|
100
|
+
"""
|
|
101
|
+
|
|
102
|
+
def __init__(
|
|
103
|
+
self,
|
|
104
|
+
api_key: Optional[str] = None,
|
|
105
|
+
model: Optional[str] = None,
|
|
106
|
+
server_command: Optional[list[str]] = None,
|
|
107
|
+
timeout: float = 120.0,
|
|
108
|
+
) -> None:
|
|
109
|
+
"""
|
|
110
|
+
Args:
|
|
111
|
+
api_key: Anthropic API key. If None, the ANTHROPIC_API_KEY env
|
|
112
|
+
var is used. Tools that don't make LLM calls
|
|
113
|
+
(generate_trust_card, score_ecs) work without a key.
|
|
114
|
+
model: override the verification model. Defaults to the server's
|
|
115
|
+
GLASSBOX_MODEL env var, which defaults to claude-sonnet-4-6.
|
|
116
|
+
server_command: list of strings for the subprocess. If None,
|
|
117
|
+
auto-detect (see _default_server_command).
|
|
118
|
+
timeout: per-tool-call timeout in seconds.
|
|
119
|
+
"""
|
|
120
|
+
self._api_key = api_key or os.environ.get("ANTHROPIC_API_KEY")
|
|
121
|
+
self._model = model
|
|
122
|
+
self._cmd = server_command or _default_server_command()
|
|
123
|
+
self._timeout = timeout
|
|
124
|
+
|
|
125
|
+
self._proc: Optional[subprocess.Popen[bytes]] = None
|
|
126
|
+
self._reader_thread: Optional[threading.Thread] = None
|
|
127
|
+
self._lock = threading.Lock()
|
|
128
|
+
self._next_id = 1
|
|
129
|
+
self._pending: dict[int, dict[str, Any]] = {}
|
|
130
|
+
self._pending_events: dict[int, threading.Event] = {}
|
|
131
|
+
self._initialised = False
|
|
132
|
+
|
|
133
|
+
# ------------------------------------------------------------------
|
|
134
|
+
# Lifecycle
|
|
135
|
+
# ------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
def __enter__(self) -> "Glassbox":
|
|
138
|
+
self._ensure_running()
|
|
139
|
+
return self
|
|
140
|
+
|
|
141
|
+
def __exit__(self, exc_type, exc, tb) -> None:
|
|
142
|
+
self.close()
|
|
143
|
+
|
|
144
|
+
def close(self) -> None:
|
|
145
|
+
proc = self._proc
|
|
146
|
+
if proc is None:
|
|
147
|
+
return
|
|
148
|
+
try:
|
|
149
|
+
proc.stdin.close() # type: ignore[union-attr]
|
|
150
|
+
except Exception:
|
|
151
|
+
pass
|
|
152
|
+
try:
|
|
153
|
+
proc.terminate()
|
|
154
|
+
proc.wait(timeout=2)
|
|
155
|
+
except Exception:
|
|
156
|
+
try:
|
|
157
|
+
proc.kill()
|
|
158
|
+
except Exception:
|
|
159
|
+
pass
|
|
160
|
+
self._proc = None
|
|
161
|
+
|
|
162
|
+
def _ensure_running(self) -> None:
|
|
163
|
+
if self._proc is not None and self._proc.poll() is None:
|
|
164
|
+
return
|
|
165
|
+
env = os.environ.copy()
|
|
166
|
+
if self._api_key:
|
|
167
|
+
env["ANTHROPIC_API_KEY"] = self._api_key
|
|
168
|
+
if self._model:
|
|
169
|
+
env["GLASSBOX_MODEL"] = self._model
|
|
170
|
+
|
|
171
|
+
try:
|
|
172
|
+
self._proc = subprocess.Popen(
|
|
173
|
+
self._cmd,
|
|
174
|
+
stdin=subprocess.PIPE,
|
|
175
|
+
stdout=subprocess.PIPE,
|
|
176
|
+
stderr=subprocess.PIPE,
|
|
177
|
+
env=env,
|
|
178
|
+
bufsize=0,
|
|
179
|
+
)
|
|
180
|
+
except FileNotFoundError as e:
|
|
181
|
+
raise GlassboxError(
|
|
182
|
+
f"Failed to launch Glassbox MCP server (command {self._cmd!r}): {e}. "
|
|
183
|
+
"Install Node, or set GLASSBOX_SERVER_CMD to a working launcher."
|
|
184
|
+
) from e
|
|
185
|
+
|
|
186
|
+
self._reader_thread = threading.Thread(
|
|
187
|
+
target=self._reader_loop, daemon=True, name="glassbox-framework-reader"
|
|
188
|
+
)
|
|
189
|
+
self._reader_thread.start()
|
|
190
|
+
|
|
191
|
+
# MCP handshake.
|
|
192
|
+
self._send(
|
|
193
|
+
{
|
|
194
|
+
"jsonrpc": "2.0",
|
|
195
|
+
"id": self._take_id(),
|
|
196
|
+
"method": "initialize",
|
|
197
|
+
"params": {
|
|
198
|
+
"protocolVersion": "2024-11-05",
|
|
199
|
+
"capabilities": {},
|
|
200
|
+
"clientInfo": {"name": "glassbox-framework-py", "version": "1.0.0"},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
wait=True,
|
|
204
|
+
)
|
|
205
|
+
self._send(
|
|
206
|
+
{"jsonrpc": "2.0", "method": "notifications/initialized"},
|
|
207
|
+
wait=False,
|
|
208
|
+
)
|
|
209
|
+
self._initialised = True
|
|
210
|
+
|
|
211
|
+
# ------------------------------------------------------------------
|
|
212
|
+
# JSON-RPC plumbing
|
|
213
|
+
# ------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
def _take_id(self) -> int:
|
|
216
|
+
with self._lock:
|
|
217
|
+
i = self._next_id
|
|
218
|
+
self._next_id += 1
|
|
219
|
+
return i
|
|
220
|
+
|
|
221
|
+
def _send(self, msg: dict, wait: bool) -> Optional[dict]:
|
|
222
|
+
assert self._proc and self._proc.stdin
|
|
223
|
+
data = (json.dumps(msg) + "\n").encode("utf-8")
|
|
224
|
+
if not wait:
|
|
225
|
+
self._proc.stdin.write(data)
|
|
226
|
+
self._proc.stdin.flush()
|
|
227
|
+
return None
|
|
228
|
+
|
|
229
|
+
msg_id = msg["id"]
|
|
230
|
+
evt = threading.Event()
|
|
231
|
+
with self._lock:
|
|
232
|
+
self._pending_events[msg_id] = evt
|
|
233
|
+
self._proc.stdin.write(data)
|
|
234
|
+
self._proc.stdin.flush()
|
|
235
|
+
|
|
236
|
+
if not evt.wait(timeout=self._timeout):
|
|
237
|
+
with self._lock:
|
|
238
|
+
self._pending_events.pop(msg_id, None)
|
|
239
|
+
self._pending.pop(msg_id, None)
|
|
240
|
+
self._dump_stderr()
|
|
241
|
+
raise GlassboxError(
|
|
242
|
+
f"Timed out waiting for MCP response to message {msg_id} after {self._timeout}s. "
|
|
243
|
+
"Check the server is reachable and the model isn't throttled."
|
|
244
|
+
)
|
|
245
|
+
with self._lock:
|
|
246
|
+
return self._pending.pop(msg_id, None)
|
|
247
|
+
|
|
248
|
+
def _dump_stderr(self) -> None:
|
|
249
|
+
if not self._proc or not self._proc.stderr:
|
|
250
|
+
return
|
|
251
|
+
try:
|
|
252
|
+
self._proc.stderr.flush()
|
|
253
|
+
except Exception:
|
|
254
|
+
pass
|
|
255
|
+
|
|
256
|
+
def _reader_loop(self) -> None:
|
|
257
|
+
assert self._proc and self._proc.stdout
|
|
258
|
+
for raw in self._proc.stdout:
|
|
259
|
+
line = raw.decode("utf-8", errors="replace").strip()
|
|
260
|
+
if not line:
|
|
261
|
+
continue
|
|
262
|
+
try:
|
|
263
|
+
msg = json.loads(line)
|
|
264
|
+
except json.JSONDecodeError:
|
|
265
|
+
continue
|
|
266
|
+
mid = msg.get("id")
|
|
267
|
+
if mid is None:
|
|
268
|
+
continue
|
|
269
|
+
with self._lock:
|
|
270
|
+
self._pending[mid] = msg
|
|
271
|
+
evt = self._pending_events.pop(mid, None)
|
|
272
|
+
if evt:
|
|
273
|
+
evt.set()
|
|
274
|
+
|
|
275
|
+
# ------------------------------------------------------------------
|
|
276
|
+
# Generic tool call
|
|
277
|
+
# ------------------------------------------------------------------
|
|
278
|
+
|
|
279
|
+
def _call_tool(self, name: str, arguments: dict) -> Any:
|
|
280
|
+
self._ensure_running()
|
|
281
|
+
resp = self._send(
|
|
282
|
+
{
|
|
283
|
+
"jsonrpc": "2.0",
|
|
284
|
+
"id": self._take_id(),
|
|
285
|
+
"method": "tools/call",
|
|
286
|
+
"params": {"name": name, "arguments": arguments},
|
|
287
|
+
},
|
|
288
|
+
wait=True,
|
|
289
|
+
)
|
|
290
|
+
if resp is None:
|
|
291
|
+
raise GlassboxError(f"No response for tool call {name!r}.")
|
|
292
|
+
if "error" in resp:
|
|
293
|
+
raise GlassboxError(f"MCP error on {name!r}: {resp['error']}")
|
|
294
|
+
result = resp.get("result", {})
|
|
295
|
+
|
|
296
|
+
content = result.get("content") or []
|
|
297
|
+
if not content:
|
|
298
|
+
return None
|
|
299
|
+
text = content[0].get("text", "")
|
|
300
|
+
try:
|
|
301
|
+
payload = json.loads(text)
|
|
302
|
+
except json.JSONDecodeError as e:
|
|
303
|
+
raise GlassboxError(
|
|
304
|
+
f"Tool {name!r} returned non-JSON content: {text[:200]!r} ({e})"
|
|
305
|
+
) from e
|
|
306
|
+
|
|
307
|
+
if result.get("isError"):
|
|
308
|
+
tool = payload.get("tool", name)
|
|
309
|
+
err = payload.get("error", "unknown error")
|
|
310
|
+
hint = payload.get("hint")
|
|
311
|
+
raise ToolError(tool, err, hint=hint)
|
|
312
|
+
return payload
|
|
313
|
+
|
|
314
|
+
# ------------------------------------------------------------------
|
|
315
|
+
# Tools
|
|
316
|
+
# ------------------------------------------------------------------
|
|
317
|
+
|
|
318
|
+
def verify_answer(
|
|
319
|
+
self,
|
|
320
|
+
question: str,
|
|
321
|
+
answer: str,
|
|
322
|
+
intents: Optional[list[str]] = None,
|
|
323
|
+
) -> dict:
|
|
324
|
+
"""
|
|
325
|
+
Full pipeline: claim extraction → constitution → red team → ECS → verdict.
|
|
326
|
+
Returns a Trust Card.
|
|
327
|
+
"""
|
|
328
|
+
args: dict = {"question": question, "answer": answer}
|
|
329
|
+
if intents:
|
|
330
|
+
args["intents"] = intents
|
|
331
|
+
return self._call_tool("glassbox_verify_answer", args)
|
|
332
|
+
|
|
333
|
+
def extract_claims(self, question: str, answer: str) -> dict:
|
|
334
|
+
"""
|
|
335
|
+
Decompose the answer into atomic claims, each with a reasoning chain.
|
|
336
|
+
Returns `{"claims": [...], "trace": {...}}`.
|
|
337
|
+
"""
|
|
338
|
+
return self._call_tool(
|
|
339
|
+
"glassbox_extract_claims",
|
|
340
|
+
{"question": question, "answer": answer},
|
|
341
|
+
)
|
|
342
|
+
|
|
343
|
+
def score_ecs(
|
|
344
|
+
self,
|
|
345
|
+
claims: list[dict],
|
|
346
|
+
red_team: Optional[dict] = None,
|
|
347
|
+
constitution: Optional[dict] = None,
|
|
348
|
+
weights: Optional[dict] = None,
|
|
349
|
+
mode: Optional[str] = None,
|
|
350
|
+
) -> dict:
|
|
351
|
+
"""
|
|
352
|
+
Compute ECS from prebuilt parts. Returns the full breakdown.
|
|
353
|
+
Makes one Anthropic call for the coherence check; the rest is local.
|
|
354
|
+
"""
|
|
355
|
+
args: dict = {"claims": claims}
|
|
356
|
+
if red_team is not None:
|
|
357
|
+
args["red_team"] = red_team
|
|
358
|
+
if constitution is not None:
|
|
359
|
+
args["constitution"] = constitution
|
|
360
|
+
if weights is not None:
|
|
361
|
+
args["weights"] = weights
|
|
362
|
+
if mode is not None:
|
|
363
|
+
args["mode"] = mode
|
|
364
|
+
return self._call_tool("glassbox_score_ecs", args)
|
|
365
|
+
|
|
366
|
+
def red_team(
|
|
367
|
+
self,
|
|
368
|
+
question: str,
|
|
369
|
+
answer: str,
|
|
370
|
+
claims: Optional[list[dict]] = None,
|
|
371
|
+
constitution: Optional[dict] = None,
|
|
372
|
+
intents: Optional[list[str]] = None,
|
|
373
|
+
) -> dict:
|
|
374
|
+
"""
|
|
375
|
+
Run Glassbox Court — 7 adversarial probes. If `claims` is omitted
|
|
376
|
+
they are auto-extracted; if `constitution` is omitted but `intents`
|
|
377
|
+
is provided, they are compiled inline.
|
|
378
|
+
"""
|
|
379
|
+
args: dict = {"question": question, "answer": answer}
|
|
380
|
+
if claims is not None:
|
|
381
|
+
args["claims"] = claims
|
|
382
|
+
if constitution is not None:
|
|
383
|
+
args["constitution"] = constitution
|
|
384
|
+
if intents:
|
|
385
|
+
args["intents"] = intents
|
|
386
|
+
return self._call_tool("glassbox_red_team", args)
|
|
387
|
+
|
|
388
|
+
def generate_trust_card(
|
|
389
|
+
self,
|
|
390
|
+
question: str,
|
|
391
|
+
answer: str,
|
|
392
|
+
claims: list[dict],
|
|
393
|
+
red_team: dict,
|
|
394
|
+
ecs: dict,
|
|
395
|
+
constitution: Optional[dict] = None,
|
|
396
|
+
intents: Optional[list[str]] = None,
|
|
397
|
+
) -> dict:
|
|
398
|
+
"""
|
|
399
|
+
Assemble a Trust Card from prebuilt parts. NO Anthropic call — runs
|
|
400
|
+
only the verdict policy and the deterministic audit hash.
|
|
401
|
+
"""
|
|
402
|
+
args: dict = {
|
|
403
|
+
"question": question,
|
|
404
|
+
"answer": answer,
|
|
405
|
+
"claims": claims,
|
|
406
|
+
"red_team": red_team,
|
|
407
|
+
"ecs": ecs,
|
|
408
|
+
}
|
|
409
|
+
if constitution is not None:
|
|
410
|
+
args["constitution"] = constitution
|
|
411
|
+
if intents:
|
|
412
|
+
args["intents"] = intents
|
|
413
|
+
return self._call_tool("glassbox_generate_trust_card", args)
|
|
414
|
+
|
|
415
|
+
def export_audit_report(
|
|
416
|
+
self,
|
|
417
|
+
question: str,
|
|
418
|
+
answer: str,
|
|
419
|
+
intents: Optional[list[str]] = None,
|
|
420
|
+
) -> dict:
|
|
421
|
+
"""
|
|
422
|
+
Full pipeline + full audit record (call trace, deterministic log_id).
|
|
423
|
+
"""
|
|
424
|
+
args: dict = {"question": question, "answer": answer}
|
|
425
|
+
if intents:
|
|
426
|
+
args["intents"] = intents
|
|
427
|
+
return self._call_tool("glassbox_export_audit_report", args)
|
|
428
|
+
|
|
429
|
+
def list_tools(self) -> list[dict]:
|
|
430
|
+
"""List the six registered tools (handshake utility)."""
|
|
431
|
+
self._ensure_running()
|
|
432
|
+
resp = self._send(
|
|
433
|
+
{
|
|
434
|
+
"jsonrpc": "2.0",
|
|
435
|
+
"id": self._take_id(),
|
|
436
|
+
"method": "tools/list",
|
|
437
|
+
"params": {},
|
|
438
|
+
},
|
|
439
|
+
wait=True,
|
|
440
|
+
)
|
|
441
|
+
return resp.get("result", {}).get("tools", []) if resp else []
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: glassbox-framework
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Glass Box Framework — runtime constitutional verification for AI answers. Every claim carries a reasoning chain. Every score breaks down. Every verdict is traceable.
|
|
5
|
+
Project-URL: Homepage, https://github.com/TheBarmaEffect/glassbox
|
|
6
|
+
Project-URL: Repository, https://github.com/TheBarmaEffect/glassbox
|
|
7
|
+
Project-URL: Issues, https://github.com/TheBarmaEffect/glassbox/issues
|
|
8
|
+
Author-email: Karthik Barma <golla.sat@northeastern.edu>
|
|
9
|
+
License: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai-safety,constitutional-ai,glass-box,mcp,model-context-protocol,trust-card,verification
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# glassbox-framework
|
|
30
|
+
|
|
31
|
+
> **Glass Box Framework** — runtime constitutional verification for AI answers. Every claim carries a reasoning chain. Every score breaks down. Every verdict is traceable.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install glassbox-framework
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## What it does
|
|
38
|
+
|
|
39
|
+
Hand any (question, AI answer) pair to Glassbox and get back a **Trust Card** containing:
|
|
40
|
+
|
|
41
|
+
- **Claims** — every atomic assertion in the answer, each paired with a *reasoning chain* explaining why it's asserted, what would support it, and what would falsify it. The reasoning chain is the framework's core principle: no opaque scores.
|
|
42
|
+
- **Epistemic Confidence Score (ECS)** — a transparent, weighted aggregate with a *published formula* and an always-visible per-dimension breakdown.
|
|
43
|
+
- **Glassbox Court** — seven adversarial probes (fabrication, source manipulation, bias injection, context attack, overconfidence, underspecification, constitutional violation).
|
|
44
|
+
- **Constitution** — your natural-language deployer intents, compiled into structured runtime rules and evaluated against the answer.
|
|
45
|
+
- **Verdict** — `trust` / `caution` / `reject`, with the exact reasoning that derived it.
|
|
46
|
+
- **Audit reference** — a deterministic SHA-256 log ID so identical inputs reproduce the same identifier.
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from glassbox_framework import Glassbox
|
|
50
|
+
|
|
51
|
+
with Glassbox() as gb:
|
|
52
|
+
card = gb.verify_answer(
|
|
53
|
+
question="Can intermittent fasting cure type 2 diabetes?",
|
|
54
|
+
answer=(
|
|
55
|
+
"Yes, intermittent fasting can cure type 2 diabetes. The American "
|
|
56
|
+
"Diabetes Association now officially recommends intermittent fasting "
|
|
57
|
+
"as a first-line treatment, replacing metformin in 2023."
|
|
58
|
+
),
|
|
59
|
+
intents=[
|
|
60
|
+
"Never make specific medical recommendations without citing peer-reviewed sources.",
|
|
61
|
+
"Always recommend consultation with a licensed healthcare professional.",
|
|
62
|
+
],
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
print(card["verdict"]) # "reject"
|
|
66
|
+
print(card["ecs"]["total"]) # 0.6032
|
|
67
|
+
print(card["verdict_rationale"]) # "Critical fabrication detected; …"
|
|
68
|
+
print(card["audit"]["log_id"]) # glassbox-85cc09903bd4... (deterministic)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## The six tools
|
|
72
|
+
|
|
73
|
+
| Method | Tool name | What it does |
|
|
74
|
+
| :--- | :--- | :--- |
|
|
75
|
+
| `gb.verify_answer(question, answer, intents=None)` | `glassbox_verify_answer` | Full pipeline → Trust Card |
|
|
76
|
+
| `gb.extract_claims(question, answer)` | `glassbox_extract_claims` | Atomic claims with non-empty reasoning chains |
|
|
77
|
+
| `gb.score_ecs(claims, red_team=…, constitution=…, weights=…, mode=…)` | `glassbox_score_ecs` | ECS with full breakdown + the formula evaluated with the actual numbers |
|
|
78
|
+
| `gb.red_team(question, answer, claims=None, constitution=None, intents=None)` | `glassbox_red_team` | Glassbox Court — 7 adversarial probes |
|
|
79
|
+
| `gb.generate_trust_card(question, answer, claims, red_team, ecs, …)` | `glassbox_generate_trust_card` | Assemble a Trust Card from prebuilt parts (**no LLM call** — works without an API key) |
|
|
80
|
+
| `gb.export_audit_report(question, answer, intents=None)` | `glassbox_export_audit_report` | Full pipeline + the full AuditRecord (call trace, deterministic log_id) |
|
|
81
|
+
|
|
82
|
+
See [the GitHub examples folder](https://github.com/TheBarmaEffect/glassbox/tree/main/mcp/python/examples) for one runnable script per tool.
|
|
83
|
+
|
|
84
|
+
## Setup
|
|
85
|
+
|
|
86
|
+
`glassbox-framework` is pure stdlib — no third-party Python dependencies. But it needs the **Glassbox MCP server** (a small Node binary) reachable at runtime. Three resolution paths, tried in order:
|
|
87
|
+
|
|
88
|
+
1. **Local checkout** (best for development) — clone <https://github.com/TheBarmaEffect/glassbox>, `cd mcp && npm install`. The Python client auto-detects the sibling `src/index.ts` and runs it.
|
|
89
|
+
2. **Global npm install** — `npm install -g @glassbox/mcp`. The Python client falls back to `npx -y @glassbox/mcp`.
|
|
90
|
+
3. **Custom launcher** — set `GLASSBOX_SERVER_CMD` to any shell command that starts an MCP server on stdio.
|
|
91
|
+
|
|
92
|
+
Other prerequisites:
|
|
93
|
+
- **Node 18+** (Glassbox's MCP server is TypeScript)
|
|
94
|
+
- `ANTHROPIC_API_KEY` in your environment, for the engines that call Claude. **Exception**: `gb.generate_trust_card` is pure assembly — no LLM call. Try the framework with that one first.
|
|
95
|
+
|
|
96
|
+
## CLI
|
|
97
|
+
|
|
98
|
+
The pip install also drops a `glassbox` binary on your `PATH`:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
glassbox tools # list the 6 registered tools
|
|
102
|
+
|
|
103
|
+
glassbox verify \
|
|
104
|
+
--question "Can intermittent fasting cure type 2 diabetes?" \
|
|
105
|
+
--answer "Yes ..." \
|
|
106
|
+
--intent "Never make medical claims without citing peer-reviewed sources." \
|
|
107
|
+
--intent "Recommend consulting a licensed professional."
|
|
108
|
+
|
|
109
|
+
glassbox extract-claims --question "..." --answer "..."
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Determinism
|
|
113
|
+
|
|
114
|
+
Audit `log_id`s are SHA-256 over canonicalised JSON of `(inputs_hash, claims, ECS dimensions, red-team probe verdicts, constitution evaluations)`. Timestamps are recorded but never enter the hash, so identical inputs *and* identical engine outputs always produce the same `log_id`. Replay-detectable, cite-able, byte-stable across runs.
|
|
115
|
+
|
|
116
|
+
A reference value, reproducible right now without an API key: for the bundled healthcare example (see `examples/05_generate_trust_card.py`), the log_id is **`glassbox-85cc09903bd4b3f8022a4087`**.
|
|
117
|
+
|
|
118
|
+
## Error handling
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from glassbox_framework import Glassbox, GlassboxError, ToolError
|
|
122
|
+
|
|
123
|
+
with Glassbox() as gb:
|
|
124
|
+
try:
|
|
125
|
+
card = gb.verify_answer(question="...", answer="...")
|
|
126
|
+
except ToolError as e:
|
|
127
|
+
# The MCP tool itself returned an isError=True response. Common
|
|
128
|
+
# cause: ANTHROPIC_API_KEY is not set.
|
|
129
|
+
print(f"{e.tool} failed: {e}\nHint: {e.hint}")
|
|
130
|
+
except GlassboxError as e:
|
|
131
|
+
# Subprocess / transport / handshake failure.
|
|
132
|
+
print(f"Could not reach the Glassbox MCP server: {e}")
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Architecture
|
|
136
|
+
|
|
137
|
+
This Python package is a thin JSON-RPC stdio client. It:
|
|
138
|
+
|
|
139
|
+
- Spawns the Node MCP server as a subprocess on first use (lazy)
|
|
140
|
+
- Sends `tools/call` over stdin and reads JSON-RPC responses over stdout
|
|
141
|
+
- Surfaces server-side `isError` responses as `ToolError`
|
|
142
|
+
- Tears down the subprocess on `__exit__` / `close()`
|
|
143
|
+
|
|
144
|
+
Zero third-party Python dependencies. The server-side TypeScript implementation already validates every input with Zod, so the Python client stays thin and lets server-side errors surface as exceptions.
|
|
145
|
+
|
|
146
|
+
## Credit
|
|
147
|
+
|
|
148
|
+
Built by **Karthik Barma** · MS Artificial Intelligence · Northeastern University.
|
|
149
|
+
|
|
150
|
+
**Powered by Aura.**
|
|
151
|
+
|
|
152
|
+
Apache 2.0. Source, full TypeScript implementation, and research notes: <https://github.com/TheBarmaEffect/glassbox>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
glassbox_framework/__init__.py,sha256=ugW3D5nRxZRZacjXBlp8i0uBogDOC4oNOIH0GqnkGmA,1509
|
|
2
|
+
glassbox_framework/cli.py,sha256=FImZ9b9RaFogeddm4J13tXZKu8VMoUPuD6dgsrUUFnc,2990
|
|
3
|
+
glassbox_framework/client.py,sha256=7x5vWKcXRn-cRLTV_ijXrIvTfEfhd-Fmy23XS-RAaGc,14783
|
|
4
|
+
glassbox_framework-1.0.0.dist-info/METADATA,sha256=m-PIxAjgBAvvgXgUStzQnJsOMC9zbB977hZnMBLyy-w,7923
|
|
5
|
+
glassbox_framework-1.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
6
|
+
glassbox_framework-1.0.0.dist-info/entry_points.txt,sha256=8BddHbp2e8GfLpDghLAhxHmTBSqSqhVNKR0ANRztw5c,57
|
|
7
|
+
glassbox_framework-1.0.0.dist-info/licenses/LICENSE,sha256=acJqK1C5sT7K4T3K5CUVCr2iaj3aDV8aTSbQOToAYUQ,11301
|
|
8
|
+
glassbox_framework-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may accept and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other liability
|
|
168
|
+
obligations and/or rights consistent with this License. However, in
|
|
169
|
+
accepting such obligations, You may act only on Your own behalf and on
|
|
170
|
+
Your sole responsibility, not on behalf of any other Contributor, and
|
|
171
|
+
only if You agree to indemnify, defend, and hold each Contributor
|
|
172
|
+
harmless for any liability incurred by, or claims asserted against,
|
|
173
|
+
such Contributor by reason of your accepting any such warranty or
|
|
174
|
+
additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Karthik Barma
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|