bap-ltd 1.3.5__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.
- bap_ltd-1.3.5/PKG-INFO +777 -0
- bap_ltd-1.3.5/README.md +748 -0
- bap_ltd-1.3.5/bap/__init__.py +9 -0
- bap_ltd-1.3.5/bap/__main__.py +9 -0
- bap_ltd-1.3.5/bap/bap_install.py +664 -0
- bap_ltd-1.3.5/bap/bin/darwin-amd64/bap-config.json +12 -0
- bap_ltd-1.3.5/bap/bin/darwin-amd64/bapedge +0 -0
- bap_ltd-1.3.5/bap/bin/darwin-amd64/interceptor +0 -0
- bap_ltd-1.3.5/bap/bin/darwin-amd64/policy.cedar +205 -0
- bap_ltd-1.3.5/bap/bin/darwin-amd64/schema.json +72 -0
- bap_ltd-1.3.5/bap/bin/darwin-arm64/bap-config.json +12 -0
- bap_ltd-1.3.5/bap/bin/darwin-arm64/bapedge +0 -0
- bap_ltd-1.3.5/bap/bin/darwin-arm64/interceptor +0 -0
- bap_ltd-1.3.5/bap/bin/darwin-arm64/policy.cedar +205 -0
- bap_ltd-1.3.5/bap/bin/darwin-arm64/schema.json +72 -0
- bap_ltd-1.3.5/bap/bin/linux-amd64/bap-config.json +12 -0
- bap_ltd-1.3.5/bap/bin/linux-amd64/bapedge +0 -0
- bap_ltd-1.3.5/bap/bin/linux-amd64/interceptor +0 -0
- bap_ltd-1.3.5/bap/bin/linux-amd64/policy.cedar +205 -0
- bap_ltd-1.3.5/bap/bin/linux-amd64/schema.json +72 -0
- bap_ltd-1.3.5/bap/bin/linux-arm64/bap-config.json +12 -0
- bap_ltd-1.3.5/bap/bin/linux-arm64/bapedge +0 -0
- bap_ltd-1.3.5/bap/bin/linux-arm64/interceptor +0 -0
- bap_ltd-1.3.5/bap/bin/linux-arm64/policy.cedar +205 -0
- bap_ltd-1.3.5/bap/bin/linux-arm64/schema.json +72 -0
- bap_ltd-1.3.5/bap/bin/windows-amd64/bap-config.json +12 -0
- bap_ltd-1.3.5/bap/bin/windows-amd64/bapedge.exe +0 -0
- bap_ltd-1.3.5/bap/bin/windows-amd64/interceptor.exe +0 -0
- bap_ltd-1.3.5/bap/bin/windows-amd64/policy.cedar +205 -0
- bap_ltd-1.3.5/bap/bin/windows-amd64/schema.json +72 -0
- bap_ltd-1.3.5/bap/cli.py +110 -0
- bap_ltd-1.3.5/bap/doctor.py +34 -0
- bap_ltd-1.3.5/bap/install.py +34 -0
- bap_ltd-1.3.5/bap/launch.py +34 -0
- bap_ltd-1.3.5/bap/sdk.py +18 -0
- bap_ltd-1.3.5/bap_ltd.egg-info/PKG-INFO +777 -0
- bap_ltd-1.3.5/bap_ltd.egg-info/SOURCES.txt +83 -0
- bap_ltd-1.3.5/bap_ltd.egg-info/dependency_links.txt +1 -0
- bap_ltd-1.3.5/bap_ltd.egg-info/entry_points.txt +4 -0
- bap_ltd-1.3.5/bap_ltd.egg-info/top_level.txt +1 -0
- bap_ltd-1.3.5/pyproject.toml +46 -0
- bap_ltd-1.3.5/setup.cfg +4 -0
- bap_ltd-1.3.5/setup.py +45 -0
- bap_ltd-1.3.5/tests/test_agent_watch_v2.py +135 -0
- bap_ltd-1.3.5/tests/test_bap200_sole_executor.py +568 -0
- bap_ltd-1.3.5/tests/test_bap714_containment_redteam.py +180 -0
- bap_ltd-1.3.5/tests/test_bap_530_egress_control.py +264 -0
- bap_ltd-1.3.5/tests/test_bap_534_535_538.py +123 -0
- bap_ltd-1.3.5/tests/test_bap_536_adversarial_scanner.py +185 -0
- bap_ltd-1.3.5/tests/test_bap_537_tamper_and_quarantine.py +286 -0
- bap_ltd-1.3.5/tests/test_bap_539_multi_harness.py +353 -0
- bap_ltd-1.3.5/tests/test_bap_epic32_agent_auth.py +481 -0
- bap_ltd-1.3.5/tests/test_bap_install_multiplatform.py +161 -0
- bap_ltd-1.3.5/tests/test_bounded_authority_matrix.py +453 -0
- bap_ltd-1.3.5/tests/test_cedar_policy_studio.py +338 -0
- bap_ltd-1.3.5/tests/test_control_plane.py +689 -0
- bap_ltd-1.3.5/tests/test_crash_recovery_sweep.py +270 -0
- bap_ltd-1.3.5/tests/test_demo_remote_cio.py +81 -0
- bap_ltd-1.3.5/tests/test_e2e_adversarial_hardening.py +518 -0
- bap_ltd-1.3.5/tests/test_e2e_full_lifecycle.py +670 -0
- bap_ltd-1.3.5/tests/test_endpoint_layered_enforcement.py +262 -0
- bap_ltd-1.3.5/tests/test_enterprise_idp_oidc.py +187 -0
- bap_ltd-1.3.5/tests/test_executive_demo.py +314 -0
- bap_ltd-1.3.5/tests/test_gateway_pep.py +186 -0
- bap_ltd-1.3.5/tests/test_governance_extension.py +379 -0
- bap_ltd-1.3.5/tests/test_harness_multi_session.py +210 -0
- bap_ltd-1.3.5/tests/test_hitl_and_supply_chain.py +394 -0
- bap_ltd-1.3.5/tests/test_http_client_auto_grant.py +171 -0
- bap_ltd-1.3.5/tests/test_intent_telemetry.py +262 -0
- bap_ltd-1.3.5/tests/test_kms_audit_notarization.py +203 -0
- bap_ltd-1.3.5/tests/test_leak.py +58 -0
- bap_ltd-1.3.5/tests/test_mcp_server.py +272 -0
- bap_ltd-1.3.5/tests/test_multi_layer_defense.py +378 -0
- bap_ltd-1.3.5/tests/test_packaging_and_cicd.py +139 -0
- bap_ltd-1.3.5/tests/test_persona_activity.py +344 -0
- bap_ltd-1.3.5/tests/test_private_credentials_and_certs.py +70 -0
- bap_ltd-1.3.5/tests/test_prompt_injection_defense.py +264 -0
- bap_ltd-1.3.5/tests/test_python_agent.py +116 -0
- bap_ltd-1.3.5/tests/test_python_agent_negative.py +51 -0
- bap_ltd-1.3.5/tests/test_scoped_pinning_and_sweep.py +123 -0
- bap_ltd-1.3.5/tests/test_shadow_it_discovery.py +428 -0
- bap_ltd-1.3.5/tests/test_spiffe_tpm_kernel_sandboxing.py +283 -0
- bap_ltd-1.3.5/tests/test_stop_revoke_lifecycle.py +188 -0
- bap_ltd-1.3.5/tests/test_vendor_interop.py +107 -0
- bap_ltd-1.3.5/tests/test_version_compatibility.py +264 -0
bap_ltd-1.3.5/PKG-INFO
ADDED
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bap-ltd
|
|
3
|
+
Version: 1.3.5
|
|
4
|
+
Summary: Bounded Authority Plane (BAP) - Zero-Trust Local Trusted Daemon & Governance for AI Developer Agents
|
|
5
|
+
Home-page: https://bap-controlplane.onrender.com
|
|
6
|
+
Author: BAP Security Architecture Team
|
|
7
|
+
Author-email: BAP Security Architecture Team <security@bapltd.com>
|
|
8
|
+
License: Apache-2.0
|
|
9
|
+
Project-URL: Homepage, https://bap-controlplane.onrender.com
|
|
10
|
+
Project-URL: Documentation, https://github.com/anandnomura/bapltd/blob/main/docs/ONBOARDING.md
|
|
11
|
+
Project-URL: Repository, https://github.com/anandnomura/bapltd
|
|
12
|
+
Keywords: bap,zero-trust,ai-agents,security,governance,claude-code,antigravity,copilot,spiffe,cedar-policy
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Intended Audience :: Information Technology
|
|
16
|
+
Classifier: Intended Audience :: System Administrators
|
|
17
|
+
Classifier: Topic :: Security
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Requires-Python: >=3.8
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: requires-python
|
|
29
|
+
|
|
30
|
+
# 🛡️ Bounded Authority Plane (BAP)
|
|
31
|
+
|
|
32
|
+
### Identity, Zero Standing Privilege, and Runtime Authorization for AI Agents
|
|
33
|
+
|
|
34
|
+
> **"The human requested the work. The agent performed the action. The enterprise must be able to independently prove both, bound the blast radius to zero, and guarantee that intent is never mistaken for authority."**
|
|
35
|
+
|
|
36
|
+
BAP is an open reference architecture and implementation for governing AI agents (Claude Code, GitHub Copilot CLI, autonomous worker scripts, and MCP toolchains) that execute commands, touch source files, call APIs, and access enterprise resources.
|
|
37
|
+
|
|
38
|
+
📖 **Core Documentation Links:**
|
|
39
|
+
- [🚀 5-Minute Developer Onboarding Guide (`docs/ONBOARDING.md`)](docs/ONBOARDING.md) — Single-click user-mode setup for Claude Code, Antigravity, Copilot, Cursor & Python.
|
|
40
|
+
- [📰 Launch Blog & Announcement (`docs/BLOG_LAUNCH_ANNOUNCEMENT.md`)](docs/BLOG_LAUNCH_ANNOUNCEMENT.md) — Why Autonomous AI Coding Agents Demand a Bounded Authority Plane.
|
|
41
|
+
- [📋 Enterprise Pilot Runbook & Evaluation Protocol (`docs/PILOT_RUNBOOK.md`)](docs/PILOT_RUNBOOK.md) — 30-Day implementation guide for CISOs, Platform Engineering & DevLeads.
|
|
42
|
+
- [🛡️ Security Assurance & Enterprise FAQ (`docs/FAQ_AND_SECURITY_ASSURANCE.md`)](docs/FAQ_AND_SECURITY_ASSURANCE.md) — Privacy, zero code exfiltration, compliance, and threat mitigation.
|
|
43
|
+
- [🏢 Enterprise Fleet Deployment (`docs/ENTERPRISE_DEPLOYMENT.md`)](docs/ENTERPRISE_DEPLOYMENT.md) — IT Admin guide for Intune, Jamf, GPO, and Ansible rollouts.
|
|
44
|
+
- [🐍 Python Agent SDK Guide (`docs/PYTHON_SDK_GUIDE.md`)](docs/PYTHON_SDK_GUIDE.md) — Zero-dependency governance client for custom Python autonomous agents.
|
|
45
|
+
- [🌟 Strategic Vision Document (`VISION.md`)](VISION.md) — The executive problem statement, the AI agent crisis, and strategic North Star.
|
|
46
|
+
- [🏛️ Architecture & Technical Design (`ARCHITECTURE.md`)](ARCHITECTURE.md) — Complete 4-Plane technical architecture, state machines, and threat mitigations.
|
|
47
|
+
- [📁 `.bapstate` Architecture & Troubleshooting (`docs/BAPSTATE_AND_TROUBLESHOOTING.md`)](docs/BAPSTATE_AND_TROUBLESHOOTING.md) — Unified state directory, command operations, and troubleshooting playbooks.
|
|
48
|
+
- [📋 Jira Backlog & Stories (`JIRA_Stories.md`)](JIRA_Stories.md) — Complete epics, user stories, and delivery boards (BAP-100 through BAP-743).
|
|
49
|
+
- [🔒 Security Assurance Program: BAP-700 Series (`docs/adr/ADR-004-IAM-Federation-And-Fallback.md`)](docs/adr/ADR-004-IAM-Federation-And-Fallback.md) — Enterprise Trust, Containment, Evidence, and Risk-Based Acceleration (BAP-701 to BAP-743).
|
|
50
|
+
- [🧪 10-Point Adversarial Test Matrix (`tests/test_bounded_authority_matrix.py`)](tests/test_bounded_authority_matrix.py) — 100% automated regression matrix.
|
|
51
|
+
- [🎯 Adversarial Red-Team Test Suite (`tests/test_bap714_containment_redteam.py`)](tests/test_bap714_containment_redteam.py) — Automated escape validation across 5 attack vectors.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## ⚡ Quickstart (Zero-Privilege User-Mode Install)
|
|
56
|
+
|
|
57
|
+
Install BAP via pip or directly using pure Python:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# 1. Install via PyPI
|
|
61
|
+
pip install bap-ltd
|
|
62
|
+
|
|
63
|
+
# 2. Run single-click user-mode installer (No admin / UAC required)
|
|
64
|
+
bap install
|
|
65
|
+
|
|
66
|
+
# 3. Verify workstation health with pre-flight doctor
|
|
67
|
+
bap doctor
|
|
68
|
+
|
|
69
|
+
# 4. Launch developer cockpit & verify governed agents
|
|
70
|
+
bap launch
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Or execute without package installation:
|
|
74
|
+
```bash
|
|
75
|
+
python scripts/bap_install.py
|
|
76
|
+
python scripts/bap_doctor.py
|
|
77
|
+
python scripts/bap_launch.py
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 🏛️ The Five Architectural Invariants (Baseline Core)
|
|
83
|
+
|
|
84
|
+
These foundational invariants define the non-negotiable security boundaries of BAP:
|
|
85
|
+
|
|
86
|
+
> **I1 — Intent is context, never authority.**
|
|
87
|
+
> An agent declaring intent to "update customer 123" does not grant executable privilege to write, cancel, or modify resources. Intent provides context for policy evaluation and audit evidence, never executable permission.
|
|
88
|
+
|
|
89
|
+
> **I2 — `bap-edge` determines what authority an agent may obtain; it is not assumed to execute every resulting operation.**
|
|
90
|
+
> `bap-edge` evaluates local policy and broker requests, but cannot be assumed to observe or execute every downstream HTTP/RPC call. Local intent or policy approval alone is never proof that an actual operation was authorized.
|
|
91
|
+
|
|
92
|
+
> **I3 — Actual protected operations are independently enforced at a resource-side PEP against bounded authority.**
|
|
93
|
+
> Business APIs and microservices are protected by gateway Policy Enforcement Points (PEP) that derive actual actions from trusted request characteristics (HTTP method, route, parameters), validating bounded cryptographically signed grants.
|
|
94
|
+
|
|
95
|
+
> **I4 — Control Plane owns master policy, lifecycle, and centralized state; ordinary authorization must not unnecessarily depend on a synchronous Control Plane round-trip.**
|
|
96
|
+
> The Control Plane distributes signed, immutable policy bundles. High-throughput edge decisions evaluate locally cached policies in sub-2ms; only operations requiring mutable state (e.g. single-use atomic consumption) hit central state.
|
|
97
|
+
|
|
98
|
+
> **I5 — Observability establishes causality and evidence across Runtime → Authority → PEP → Execution, but telemetry itself is never treated as authorization.**
|
|
99
|
+
> The Observability Plane reconstructs the end-to-end timeline for forensic integrity, but telemetry reporting or health signals never substitute for cryptographic authorization tokens.
|
|
100
|
+
|
|
101
|
+
### 🛡️ Four Architecture Rules (Operations & Governance Baseline)
|
|
102
|
+
|
|
103
|
+
> **R1 — Proposals are immutable.** Correction creates lineage (`parent_proposal_id`), never mutation of existing proposals.
|
|
104
|
+
> **R2 — Humans remediate inputs, never override decisions.** Changed input goes through full policy governance again. No human operator overrides authorization outcomes directly.
|
|
105
|
+
> **R3 — Authorization does not prove execution.** PEP authorization and actual backend completion are separately evidenced. If network failure occurs post-authorization, state is marked `UNKNOWN` and reconciled; authorization is never assumed to be execution.
|
|
106
|
+
> **R4 — Operating the governance system is itself governed.** Administrative privilege must never become the back door around bounded authority. BAP governs BAP.
|
|
107
|
+
|
|
108
|
+
**Extended Governance Chain:**
|
|
109
|
+
$$\text{Task} \longrightarrow \text{Intent Context} \longrightarrow \text{Action Proposal} \longrightarrow \text{Policy Decision} \longrightarrow \text{Bounded Grant} \longrightarrow \text{Gateway PEP} \longrightarrow \text{Execution} \longrightarrow \text{Evidence}$$
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## 🧪 The 10-Point Architectural Adversarial Matrix
|
|
114
|
+
|
|
115
|
+
Every pull request and security enhancement must pass the 10 adversarial scenarios:
|
|
116
|
+
|
|
117
|
+
```text
|
|
118
|
+
Can a compromised or misbehaving agent:
|
|
119
|
+
1. Claim a different intent? --> BLOCKED (I1)
|
|
120
|
+
2. Modify its requested authority? --> BLOCKED (I3, HMAC Signature)
|
|
121
|
+
3. Use a grant against another resource? --> BLOCKED (I3, Path Derivation)
|
|
122
|
+
4. Perform an additional operation (Header Spoofing)? --> BLOCKED (I3, deriveOperation)
|
|
123
|
+
5. Reuse or over-consume a constrained grant? --> BLOCKED (I4, Atomic Burn)
|
|
124
|
+
6. Execute operations concurrently to bypass limits? --> BLOCKED (I4, Mutex Lock)
|
|
125
|
+
7. Bypass bap-edge (Tampering with policies/assets)? --> BLOCKED (I2, Interceptor Gate)
|
|
126
|
+
8. Bypass Gateway PEP (Direct unauthenticated access)? --> BLOCKED (I3, 401 Rogue Drop)
|
|
127
|
+
9. Exploit unknown or ambiguous prompts? --> BLOCKED (I1, UNKNOWN Safe Fallback)
|
|
128
|
+
10. Forge the historical audit trail? --> BLOCKED (I5, Merkle Hash Chain)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Run the Full Matrix in 1 Second:
|
|
132
|
+
```powershell
|
|
133
|
+
python -m unittest tests/test_bounded_authority_matrix.py -v
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## 🚀 System Topology: The Four Operating Planes
|
|
139
|
+
|
|
140
|
+
BAP decomposes AI agent governance into four decoupled, resilient planes:
|
|
141
|
+
|
|
142
|
+
```mermaid
|
|
143
|
+
flowchart LR
|
|
144
|
+
subgraph HumanAgent ["1. Edge Execution Plane (Workstation / Container)"]
|
|
145
|
+
HUMAN["Human Developer"]
|
|
146
|
+
AGENT["AI Agent (Claude / Copilot)"]
|
|
147
|
+
EDGE["bap-edge / cchook (Local PEP)"]
|
|
148
|
+
HUMAN -->|Prompt| AGENT
|
|
149
|
+
AGENT -->|Tool / Command| EDGE
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
subgraph ControlPlane ["2. Central Control Plane (bapcontrolplane)"]
|
|
153
|
+
REG["Agent Registry & SPIFFE"]
|
|
154
|
+
CEDAR["Authoritative Cedar Policies"]
|
|
155
|
+
MINTER["Cryptographic Grant Minter"]
|
|
156
|
+
STATE["Atomic Grant Burner (maxUses=1)"]
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
subgraph GatewayPlane ["3. Resource Enforcement Plane (bapgateway)"]
|
|
160
|
+
PEP["Zero-Trust Gateway PEP"]
|
|
161
|
+
API["Internal Microservices / DB"]
|
|
162
|
+
PEP -->|Authorized Request| API
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
subgraph ObservabilityPlane ["4. Observability & Forensic Plane"]
|
|
166
|
+
COCKPIT["CIO Fleet Command Cockpit"]
|
|
167
|
+
AUDIT["Tamper-Evident Merkle Hash Store"]
|
|
168
|
+
COCKPIT --> AUDIT
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
%% Interactions
|
|
172
|
+
EDGE <-->|Sub-2ms Local Policy Sync| CEDAR
|
|
173
|
+
EDGE <-->|Acquire Bounded Grant| MINTER
|
|
174
|
+
EDGE -->|Emit Intent & Tool Events| AUDIT
|
|
175
|
+
AGENT -->|HTTP with Grant Bearer| PEP
|
|
176
|
+
PEP <-->|Synchronous Atomic Consume| STATE
|
|
177
|
+
PEP -->|Emit PEP Decision Audit| AUDIT
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
1. **Control Plane (`bapcontrolplane`):** Authoritative Cedar policy master, SPIFFE SVID workload identity issuance, ephemeral bounded grant minting, and atomic single-use state burning.
|
|
181
|
+
2. **Edge Execution Broker (`bapedge` / `cchook` / `copilot`):** Embeds pure-Go AWS Cedar engine for **sub-2ms local evaluation**, enforces command containment, and deterministically classifies mission intent into 11 CIO categories.
|
|
182
|
+
3. **Gateway PEP (`bapgateway`):** Independent zero-trust boundary in front of business APIs. Autonomously derives required operations (`deriveOperation`) from HTTP attributes, rejects spoofed headers, and burns single-use grants.
|
|
183
|
+
4. **Observability Plane:** Cryptographically links `Intent -> Authority -> PEP -> Execution` into a SHA-256 Merkle chain and visualizes live fleet health on the CIO Cockpit.
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## ⚡ Quickstart & Interactive Testing
|
|
188
|
+
|
|
189
|
+
### 🚀 Governed Agent Launchers (Production 1-Click Runtimes)
|
|
190
|
+
|
|
191
|
+
BAP provides dedicated zero-trust launchers for all major developer coding assistants, with automatic workspace policy mounting, liveness monitoring, token telemetry, and clean teardown:
|
|
192
|
+
|
|
193
|
+
| Launcher Script | Agent Runtime | Capabilities & Zero-Trust Governance |
|
|
194
|
+
| :--- | :--- | :--- |
|
|
195
|
+
| [`run_claude_bap.bat`](file:///c:/Users/User/pyprj/bapltd/run_claude_bap.bat) | **Claude Code CLI** | Multi-instance concurrency, reference-counted custody locks, transactional `settings.json` backup/restore, `cchook/interceptor.exe` hook integration. |
|
|
196
|
+
| [`run_antigravity_ide_bap.bat`](file:///c:/Users/User/pyprj/bapltd/run_antigravity_ide_bap.bat) | **Google Antigravity (IDE)** | Electron GUI process supervision (prevents premature exit), holds session active in Control Plane, live high-speed `transcript.jsonl` streaming, `GEMINI.md` policy and MCP injection. |
|
|
197
|
+
| [`run_antigravity_cli_bap.bat`](file:///c:/Users/User/pyprj/bapltd/run_antigravity_cli_bap.bat) | **Google Antigravity (CLI)** | Transactional CLI execution (`agy.exe`) under full BAP workspace and command containment. |
|
|
198
|
+
| [`run_copilot_cli_bap.bat`](file:///c:/Users/User/pyprj/bapltd/run_copilot_cli_bap.bat) | **GitHub Copilot CLI** | Prioritizes standalone `copilot.exe` (v1.0.97+) with `gh copilot` fallback, live `events.jsonl` telemetry tailing, `AGENTS.md` and MCP server injection, exit token & credit accounting snapshot. |
|
|
199
|
+
| [`run_agent_demo.bat`](file:///c:/Users/User/pyprj/bapltd/run_agent_demo.bat) | **Multi-Agent Fleet Demo** | Interactive squad demo (Python SDK + Claude Code) with dynamic scaling and live Cockpit radar validation. |
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### Option 1: Automated Regression & End-to-End Suites
|
|
204
|
+
```powershell
|
|
205
|
+
# Run complete test discovery across all 79 unit, integration & E2E tests
|
|
206
|
+
python -m unittest discover tests
|
|
207
|
+
|
|
208
|
+
# Run 10-stage End-to-End (E2E) Full Mission Lifecycle Suite
|
|
209
|
+
python -m unittest tests/test_e2e_full_lifecycle.py -v
|
|
210
|
+
|
|
211
|
+
# Run End-to-End (E2E) Adversarial & Negative Security Hardening Suite
|
|
212
|
+
python -m unittest tests/test_e2e_adversarial_hardening.py -v
|
|
213
|
+
|
|
214
|
+
# Run 10-point architectural adversarial test matrix
|
|
215
|
+
python -m unittest tests/test_bounded_authority_matrix.py -v
|
|
216
|
+
|
|
217
|
+
# Run Cedar Policy Studio & "What-If" historical replay suite
|
|
218
|
+
python -m unittest tests/test_cedar_policy_studio.py -v
|
|
219
|
+
|
|
220
|
+
# Run full sole-executor & process containment suite
|
|
221
|
+
python -m unittest tests/test_bap200_sole_executor.py -v
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Option 2: Live Gateway PEP & Atomic Single-Use Testing
|
|
225
|
+
|
|
226
|
+
**1. Start Control Plane & Gateway PEP:**
|
|
227
|
+
```powershell
|
|
228
|
+
# Terminal 1: Control Plane
|
|
229
|
+
.\dist\windows-amd64\bapcontrolplane.exe -port 8080 -secret "matrix-test-signing-key-32-chars-long-ok!" -admin-token "test-admin-secret-12345" -db memory
|
|
230
|
+
|
|
231
|
+
# Terminal 2: Gateway PEP
|
|
232
|
+
.\dist\windows-amd64\bapgateway.exe -port 8090 -controlplane http://127.0.0.1:8080 -secret "matrix-test-signing-key-32-chars-long-ok!" -consume=true
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**2. Test Rogue Agent Rejection (Direct Bypass Attempt):**
|
|
236
|
+
```powershell
|
|
237
|
+
curl.exe -i http://127.0.0.1:8090/api/v1/financial-records
|
|
238
|
+
# Output: HTTP 401 Unauthorized (AccessDenied: Rogue agent lacking BAP Bearer Grant)
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**3. Test Header Spoofing Rejection:**
|
|
242
|
+
```powershell
|
|
243
|
+
curl.exe -i -X POST http://127.0.0.1:8090/api/v1/financial-records -H "X-Agent-Action: financial.records.read"
|
|
244
|
+
# Output: HTTP 401 Unauthorized (Gateway derives 'financial.records.write' and ignores header)
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**4. Test Anti-Tampering of Policy Assets:**
|
|
248
|
+
```powershell
|
|
249
|
+
echo '{"hook_event_name":"PreToolUse","tool_name":"Write","tool_input":{"file_path":"policy.cedar"}}' | .\dist\windows-amd64\interceptor.exe
|
|
250
|
+
# Output: permissionDecision: "deny" (Security Invariant Violation: Direct modification of BAP protected asset forbidden)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
## 🛡️ Epic 23: Layered Endpoint Enforcement & Workstation Hardening
|
|
256
|
+
|
|
257
|
+
BAP enforces defense-in-depth across developer workstations using an authoritative 5-layer security model:
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
261
|
+
│ LAYER 1: Cooperative Agent Hooks & Rules (User Space) │
|
|
262
|
+
│ - Claude Code PreToolUse hooks, Antigravity/Copilot workspace rules │
|
|
263
|
+
│ - MDM locks: managed-settings.json (dangerouslySkipPermissions: false)│
|
|
264
|
+
│ - UX benefit: Sub-millisecond evaluation (<1ms), native in-CLI hints │
|
|
265
|
+
└──────────────────────────────────┬─────────────────────────────────────┘
|
|
266
|
+
│ (Structured Tool Call Boundary)
|
|
267
|
+
▼
|
|
268
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
269
|
+
│ LAYER 2: Model Context Protocol (MCP) Authority Boundary │
|
|
270
|
+
│ - Managed bapmcp.exe server with Cedar policy evaluation │
|
|
271
|
+
│ - Governed bap_execute, bap_status, bap_explain_policy tools │
|
|
272
|
+
└──────────────────────────────────┬─────────────────────────────────────┘
|
|
273
|
+
│ (Unmediated Terminal & Tool Call Trap)
|
|
274
|
+
▼
|
|
275
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
276
|
+
│ LAYER 3: Tool Call & Terminal Interceptor Shims (PATH Defense) │
|
|
277
|
+
│ - Dynamic per-session shims (.bapstate/shims-$SessionId/) │
|
|
278
|
+
│ - Traps raw CLI calls (git, python, curl) and routes to bapedge exec │
|
|
279
|
+
└──────────────────────────────────┬─────────────────────────────────────┘
|
|
280
|
+
│ (Host Process & Sandbox Containment)
|
|
281
|
+
▼
|
|
282
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
283
|
+
│ LAYER 4: OS Execution & Boundary Control (Kernel / Hypervisor) │
|
|
284
|
+
│ - Windows Restricted Tokens (LUA) + Job Objects (Kill-on-Close) │
|
|
285
|
+
│ - Linux Landlock LSM (Filesystem Jail) + eBPF sys_enter_execve probe │
|
|
286
|
+
│ - macOS Endpoint Security (AUTH_EXEC, AUTH_OPEN) + Seatbelt profiles │
|
|
287
|
+
│ - Blocks hidden child subshells and theft of .env / id_rsa secrets │
|
|
288
|
+
└──────────────────────────────────┬─────────────────────────────────────┘
|
|
289
|
+
│ (Perimeter Egress Pinning & ZSP Grant)
|
|
290
|
+
▼
|
|
291
|
+
┌────────────────────────────────────────────────────────────────────────┐
|
|
292
|
+
│ LAYER 5: Authoritative Network Gateway PEP (Perimeter Backstop) │
|
|
293
|
+
│ - bapgateway Envoy ext_authz proxy with authoritative derivation │
|
|
294
|
+
│ - Single-use Zero-Trust Session Protocol (ZSP) grant burning │
|
|
295
|
+
│ - Direct egress dropped; all enterprise API traffic pinned to PEP │
|
|
296
|
+
└────────────────────────────────────────────────────────────────────────┘
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### 📋 Step-by-Step Endpoint Testing Guide
|
|
300
|
+
|
|
301
|
+
You can test and verify all Layered Endpoint Hardening features step by step using any of the three methods below:
|
|
302
|
+
|
|
303
|
+
#### Option 1: Automated Integration Test Suite (Fastest)
|
|
304
|
+
Run the dedicated Epic 23 test suite to validate all 7 verification gates:
|
|
305
|
+
```powershell
|
|
306
|
+
python -m unittest tests/test_endpoint_layered_enforcement.py
|
|
307
|
+
```
|
|
308
|
+
**Verification Evidence:**
|
|
309
|
+
- `test_01_endpoint_layers_reference`: Verifies the 5-layer defense primitive mappings across Windows, macOS, and Linux.
|
|
310
|
+
- `test_02_endpoint_compliance_managed_clean`: Verifies managed laptop with active defense layers achieves `COMPLIANT` status.
|
|
311
|
+
- `test_03_endpoint_compliance_managed_quarantine`: Verifies missing Layer 4 (Kernel Control) or Layer 5 (Gateway PEP) immediately triggers `QUARANTINED`.
|
|
312
|
+
- `test_04_endpoint_compliance_byod_cooperative`: Verifies unmanaged BYOD operates in `COOPERATIVE_BYOD` with Gateway PEP backstop.
|
|
313
|
+
- `test_05_mdm_profile_generation_intune_and_jamf`: Validates Intune CSP and Jamf mobileconfig payloads.
|
|
314
|
+
- `test_06_biometric_step_up_challenge_and_verification`: Initiates challenge, verifies biometric attestation, mints signed `StepUpToken`, and verifies replay rejection.
|
|
315
|
+
- `test_07_offline_capability_classification`: Verifies Tier 1 (Safe Local Dev) is permitted offline while Tier 2 (Cloud Egress) fails closed.
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
#### Option 2: Step-by-Step Verification via REST API (`curl.exe`)
|
|
320
|
+
|
|
321
|
+
Start the Control Plane in Terminal 1:
|
|
322
|
+
```powershell
|
|
323
|
+
.\dist\windows-amd64\bapcontrolplane.exe -port 8080 -admin-token "test-admin-token-12345" -allow-remote-admin
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
In Terminal 2, run each step-by-step verification:
|
|
327
|
+
|
|
328
|
+
**Step 2.1: Inspect 5-Layer Mappings per OS:**
|
|
329
|
+
```powershell
|
|
330
|
+
curl.exe -s http://127.0.0.1:8080/api/v1/endpoint/layers?os=windows | ConvertFrom-Json
|
|
331
|
+
curl.exe -s http://127.0.0.1:8080/api/v1/endpoint/layers?os=darwin | ConvertFrom-Json
|
|
332
|
+
curl.exe -s http://127.0.0.1:8080/api/v1/endpoint/layers?os=linux | ConvertFrom-Json
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Step 2.2: Evaluate Managed Device Compliance & Quarantine:**
|
|
336
|
+
```powershell
|
|
337
|
+
# Non-compliant device (Missing Layer B Kernel Control):
|
|
338
|
+
curl.exe -s -X POST http://127.0.0.1:8080/api/v1/endpoint/compliance `
|
|
339
|
+
-H "Content-Type: application/json" `
|
|
340
|
+
-d '{"hostname":"rogue-laptop","agent_id":"agent-1","is_managed_fleet":true,"layers":[{"layer_id":"LAYER_A_COOPERATIVE_HOOKS","active":true,"enforcing":true},{"layer_id":"LAYER_B_KERNEL_EXECUTION_CONTROL","active":false,"enforcing":false},{"layer_id":"LAYER_C_NETWORK_EGRESS_PINNING","active":true,"enforcing":true}]}'
|
|
341
|
+
# Result: "compliance_state": "QUARANTINED"
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
**Step 2.3: Generate Enterprise MDM Profiles (Intune & Jamf):**
|
|
345
|
+
```powershell
|
|
346
|
+
# Microsoft Intune (Windows CSP / JSON payload):
|
|
347
|
+
curl.exe -s http://127.0.0.1:8080/api/v1/endpoint/mdm/profile?platform=windows | ConvertFrom-Json
|
|
348
|
+
|
|
349
|
+
# Jamf Pro (macOS configuration profile):
|
|
350
|
+
curl.exe -s http://127.0.0.1:8080/api/v1/endpoint/mdm/profile?platform=macos | ConvertFrom-Json
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Step 2.4: Test Interactive Biometric Step-Up Elevation:**
|
|
354
|
+
```powershell
|
|
355
|
+
# 1. Request Step-Up challenge for high-risk action:
|
|
356
|
+
$chal = curl.exe -s -X POST http://127.0.0.1:8080/api/v1/endpoint/stepup/challenge `
|
|
357
|
+
-H "Content-Type: application/json" `
|
|
358
|
+
-d '{"agent_id":"agent-007","operation":"database.schema_migration","risk_score":0.85}' | ConvertFrom-Json
|
|
359
|
+
|
|
360
|
+
# 2. Verify biometric signature and mint StepUpToken:
|
|
361
|
+
curl.exe -s -X POST http://127.0.0.1:8080/api/v1/endpoint/stepup/verify `
|
|
362
|
+
-H "Content-Type: application/json" `
|
|
363
|
+
-d "{`"challenge_id`":`"$($chal.challenge_id)`",`"method`":`"WINDOWS_HELLO`",`"biometric_signature`":`"valid-fingerprint-sig`"}"
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Step 2.5: Test Scoped Offline Capability Classification:**
|
|
367
|
+
```powershell
|
|
368
|
+
# Safe local command -> Tier 1 (Allowed offline):
|
|
369
|
+
curl.exe -s -X POST http://127.0.0.1:8080/api/v1/endpoint/offline/classify `
|
|
370
|
+
-H "Content-Type: application/json" `
|
|
371
|
+
-d '{"operation":"pytest tests/unit"}'
|
|
372
|
+
|
|
373
|
+
# Enterprise microservice egress -> Tier 2 (Fails closed offline):
|
|
374
|
+
curl.exe -s -X POST http://127.0.0.1:8080/api/v1/endpoint/offline/classify `
|
|
375
|
+
-H "Content-Type: application/json" `
|
|
376
|
+
-d '{"operation":"POST /api/v1/core-banking/transfer"}'
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
---
|
|
380
|
+
|
|
381
|
+
#### Option 3: Visual Verification in Web Dashboard Cockpit
|
|
382
|
+
1. Launch the interactive cockpit:
|
|
383
|
+
```powershell
|
|
384
|
+
.\run_vision_demo.bat --interactive
|
|
385
|
+
```
|
|
386
|
+
2. Navigate to **`http://127.0.0.1:8080/dashboard`** in your browser.
|
|
387
|
+
3. Click the **"Endpoint Hardening"** tab:
|
|
388
|
+
- **5-Layer Architecture**: Switch OS between Windows, macOS, and Linux to see active primitives.
|
|
389
|
+
- **MDM Configuration Packaging**: Toggle between Microsoft Intune and Jamf Pro to inspect deployment payloads.
|
|
390
|
+
- **Biometric Step-Up Sandbox**: Click **"Initiate Biometric Challenge"** and then **"Touch Biometric Authenticator"** to observe live HMAC token minting and replay rejection.
|
|
391
|
+
- **Scoped Offline Degradation**: Enter any command (`cargo test`, `pytest`, `POST /api/v1/transfer`) to view the instant Tier 1 vs Tier 2 policy verdict.
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
### 9. Operational Resilience, Crash Sweeps & Developer CLI Tooling (Epic 24)
|
|
396
|
+
|
|
397
|
+
Epic 24 introduces four practical operational capabilities for developer workstations and fleet recovery:
|
|
398
|
+
|
|
399
|
+
#### 1. 1-Click Developer Setup (`bapedge setup`)
|
|
400
|
+
Idempotently configures local agent settings, sets `dangerouslySkipPermissions: false`, and wires the `PreToolUse` hook directly to `bapedge exec`:
|
|
401
|
+
```powershell
|
|
402
|
+
.\dist\windows-amd64\bapedge.exe setup --app claude-code
|
|
403
|
+
```
|
|
404
|
+
**Output:**
|
|
405
|
+
```text
|
|
406
|
+
[✓] Configured .claude\managed-settings.json
|
|
407
|
+
- dangerouslySkipPermissions: FALSE (Hardened by BAP)
|
|
408
|
+
- pre_tool_use hook: bapedge exec
|
|
409
|
+
[✓] Configured .bap\config.json
|
|
410
|
+
✅ Workstation setup complete! Agent execution is bound to Zero-Trust Policy.
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### 2. In-Terminal Workstation Inspection (`bapedge status`)
|
|
414
|
+
Inspects active local sessions, cached Cedar policy version, 5-layer defense compliance, operating mode, and offline audit spool backlog (with automatic sweep & flush on pending messages):
|
|
415
|
+
```powershell
|
|
416
|
+
.\dist\windows-amd64\bapedge.exe status
|
|
417
|
+
```
|
|
418
|
+
**Output:**
|
|
419
|
+
```text
|
|
420
|
+
Host: DESKTOP (windows/amd64)
|
|
421
|
+
Control Plane: http://localhost:8080 [CONNECTED / ONLINE (1ms)]
|
|
422
|
+
Operating Mode: STANDALONE USER-SPACE (Degraded: zero admin rights required)
|
|
423
|
+
POLICY BUNDLE & ZERO-TRUST CACHE:
|
|
424
|
+
• Version: v1
|
|
425
|
+
• Rules Digest: d70701d094...
|
|
426
|
+
• Kill Switch: false
|
|
427
|
+
5-LAYER DEFENSE-IN-DEPTH COMPLIANCE STATUS:
|
|
428
|
+
• Layer 1 (Process Interception Hooks): COMPLIANT (bapedge exec PreToolUse hook wired)
|
|
429
|
+
• Layer 2 (Model Context Protocol MCP): COMPLIANT (bapmcp server mounted with Cedar policy gate)
|
|
430
|
+
• Layer 3 (Terminal Interceptor Shims): COMPLIANT (PATH shims active for unmediated subshells)
|
|
431
|
+
• Layer 4 (OS Kernel Boundary Sandbox): COMPLIANT (Windows Job Objects & Restricted Tokens + Gateway PEP perimeter backstop active)
|
|
432
|
+
• Layer 5 (Network Perimeter Gateway PEP): COMPLIANT (Authoritative Gateway PEP perimeter backstop active)
|
|
433
|
+
TELEMETRY & OFFLINE RESILIENCE:
|
|
434
|
+
• Auto-Sync: ⚡ Auto-triggered sweep: 0 pending audit record(s) synced to Control Plane
|
|
435
|
+
• Spool Backlog: 0 pending entries (All audit logs ingested by Control Plane)
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
#### 3. In-Terminal Policy Decision Debugging (`bapedge why`)
|
|
439
|
+
Directly explains why any command is allowed or denied under local Cedar policy:
|
|
440
|
+
```powershell
|
|
441
|
+
# Safe developer action:
|
|
442
|
+
.\dist\windows-amd64\bapedge.exe why "git status"
|
|
443
|
+
# -> ✅ ALLOWED (Permitted within local workspace development boundaries)
|
|
444
|
+
|
|
445
|
+
# Dangerous action:
|
|
446
|
+
.\dist\windows-amd64\bapedge.exe why "rm -rf /"
|
|
447
|
+
# -> ⛔ DENIED (Blocked by Cedar Policy: Default deny invariant)
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
#### 4. Clean Sweep & Crash Recovery Reconciler (`bapedge sweep`)
|
|
451
|
+
Recovers from sudden laptop shutoffs, terminal force-kills, or power loss by purging orphaned process markers, releasing stale locks, flushing un-ingested offline audit batches, and synchronizing with the control plane (`/api/v1/control/sweep`):
|
|
452
|
+
```powershell
|
|
453
|
+
.\dist\windows-amd64\bapedge.exe sweep
|
|
454
|
+
```
|
|
455
|
+
**Output:**
|
|
456
|
+
```text
|
|
457
|
+
[✓] Swept 2 orphaned/crashed local session markers
|
|
458
|
+
[✓] Flushed 0 offline audit records to central tamper-evident ledger
|
|
459
|
+
[✓] Central Control Plane reconciled: 2 idle sessions closed, 1 stale grant expired
|
|
460
|
+
[✓] Workstation successfully rejoined fleet with clean state.
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
---
|
|
464
|
+
|
|
465
|
+
### 10. Agent Watch Persona Control Plane & Canonical Activity Engine (Epic 28)
|
|
466
|
+
|
|
467
|
+
Epic 28 transforms the administrative console into a persona-driven governance experience supporting four enterprise lenses over a unified zero-trust data model:
|
|
468
|
+
|
|
469
|
+
```text
|
|
470
|
+
HookWatch (Interceptors)
|
|
471
|
+
│
|
|
472
|
+
Agent Runtime (bapedge)
|
|
473
|
+
│
|
|
474
|
+
▼
|
|
475
|
+
AgentActivityEvent
|
|
476
|
+
│
|
|
477
|
+
┌─────────┼─────────┐
|
|
478
|
+
│ │ │
|
|
479
|
+
Intent Policy ZSP
|
|
480
|
+
│ │ │
|
|
481
|
+
└─────────┼─────────┘
|
|
482
|
+
▼
|
|
483
|
+
Activity / Evidence API
|
|
484
|
+
│
|
|
485
|
+
┌────────────┼────────────┐
|
|
486
|
+
│ │ │
|
|
487
|
+
CIO CISO ProdOps
|
|
488
|
+
│ │
|
|
489
|
+
└─────── IT Enablement ───┘
|
|
490
|
+
```
|
|
491
|
+
|
|
492
|
+
#### 1. Persona Control Plane Switching (`?persona=cio|ciso|ops|it`)
|
|
493
|
+
- **CIO / Business**: AI Workforce Pulse, work category distributions, business-unit adoption, and governance efficiency.
|
|
494
|
+
- **CISO / Security**: Invariant violations, quarantine controls, blast-radius mitigation, and intent deviation detection.
|
|
495
|
+
- **Prod Ops / SRE**: Fleet telemetry, interceptor health, local evaluation latencies, and grant issuance rates.
|
|
496
|
+
- **IT Enablement**: Managed catalog deployment, endpoint compliance (Layers 1–5), and MDM packaging.
|
|
497
|
+
|
|
498
|
+
#### 2. CIO AI Workforce Pulse & Live Activity Stream
|
|
499
|
+
- High-level executive pulse: Communicates active governed scale without fabricated ROI claims.
|
|
500
|
+
- **Live Work Stream**: Real-time SSE streaming (`/api/activity/stream`) of sanitized activity records.
|
|
501
|
+
- **Intent Mix & Sub-Intent Drill-Down**: Categorizes work across `Build / Change`, `Investigate / Diagnose`, `Search / Explain`, `Automate Workflow`, and `Business Analysis`.
|
|
502
|
+
- **Pure Live vs Demo Simulation**: Production defaults to pure live unsimulated telemetry (zero-state when no agents connected); demo prototype dataset (1,284 agents) is activated via `-demo-mode` or `?demo=true`.
|
|
503
|
+
|
|
504
|
+
#### 3. Enterprise Activity Topology Map
|
|
505
|
+
- Hierarchical organizational tree (`/api/activity/topology`) mapping Divisions, Teams/Workloads, and Agent Platforms (Claude Code, Copilot, Codex, Internal CLI).
|
|
506
|
+
- Interactive node filtering updates live session streams in real time.
|
|
507
|
+
|
|
508
|
+
#### 4. Intent $\rightarrow$ Action Lifecycle Contract
|
|
509
|
+
- Cryptographically tracks the 8-stage execution chain:
|
|
510
|
+
$$\text{Human Intent} \to \text{Interpretation} \to \text{Plan} \to \text{Capability} \to \text{Policy Gate} \to \text{ZSP Grant} \to \text{Observed Action} \to \text{Outcome}$$
|
|
511
|
+
- Automated **Critical Intent Deviation Detection**: Blocks side-effects when an agent performs actions inconsistent with declared human purpose (e.g. `PRODUCTION_DIAGNOSIS` attempting customer database modifications).
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
### 11. Beyond-Hook Enforcement, Daemon Supervision & Content Pinning (Epic 29)
|
|
516
|
+
|
|
517
|
+
Epic 29 elevates BAP beyond cooperative hooks and MCP wrappers into operating-system-level zero-trust enforcement, addressing multi-tenant prompt injection, hidden child processes, and dynamic skill drift:
|
|
518
|
+
|
|
519
|
+
#### 1. Background Supervisor & Two-Tier Execution (`bapedge daemon`)
|
|
520
|
+
Manages `bap-daemon`, a local background supervisor with dynamic loopback HTTP IPC (`127.0.0.1:<port>`), sub-2ms telemetry ingestion, automatic background spool flushing, and attached agent session tracking:
|
|
521
|
+
- **Degraded Mode (Standard Non-Elevated User)**: Automatically detects when running without administrator / root rights (`TokenElevation` on Windows, `UID != 0` on Unix). Disarms kernel eBPF probes and driver packet filtering while maintaining robust user-mode containment (Windows Job Objects / Landlock, IPC hub, and background spooling). **Zero admin rights required.**
|
|
522
|
+
- **Optimal Mode (Elevated Administrator / Root)**: Activates full OS-level telemetry and kernel probes.
|
|
523
|
+
|
|
524
|
+
```powershell
|
|
525
|
+
# Start daemon in background (detached process)
|
|
526
|
+
.\bapedge.exe daemon start
|
|
527
|
+
|
|
528
|
+
# Start in foreground for interactive log monitoring
|
|
529
|
+
.\bapedge.exe daemon start -foreground
|
|
530
|
+
|
|
531
|
+
# Query capability matrix, connected control plane, and IPC message throughput
|
|
532
|
+
.\bapedge.exe daemon status
|
|
533
|
+
|
|
534
|
+
# Output status in machine-readable JSON
|
|
535
|
+
.\bapedge.exe daemon status -json
|
|
536
|
+
|
|
537
|
+
# Stop daemon cleanly
|
|
538
|
+
.\bapedge.exe daemon stop
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
#### 2. Content Pinning & Dynamic Tool Attestation (`bapedge pin` — AIR Model)
|
|
542
|
+
Implements the AI Incident Response (AIR Model - BAP-531) core insight: an agent approved under an initial skill definition or prompt must never execute if the underlying file (`SKILL.md`), prompt template (`CLAUDE.md`), or MCP schema changes on disk without explicit re-attestation:
|
|
543
|
+
- **Fail-Closed on Drift**: If an attacker or dynamic prompt injection modifies a skill's `SKILL.md` or an MCP tool schema, `bapedge exec` and `bapedge mcp` immediately fail closed with `HashMismatchError`, revoking active grants and blocking execution.
|
|
544
|
+
- **Tamper-Evident Receipts**: The validated `ContentHash` is recorded directly inside `AuditEntry` and chained into BAP's sequential SHA-256 cryptographic ledger.
|
|
545
|
+
|
|
546
|
+
```powershell
|
|
547
|
+
# Auto-discover and pin workspace skills, prompt templates, and manifests
|
|
548
|
+
.\bapedge.exe pin scan
|
|
549
|
+
|
|
550
|
+
# List pinned assets with SHA-256 digests and attestation metadata
|
|
551
|
+
.\bapedge.exe pin list
|
|
552
|
+
|
|
553
|
+
# Re-verify all pinned assets against disk state (alerts on drift)
|
|
554
|
+
.\bapedge.exe pin verify
|
|
555
|
+
|
|
556
|
+
# Pin an individual custom skill, prompt, or script
|
|
557
|
+
.\bapedge.exe pin add .claude/skills/deploy/SKILL.md --id skill:deploy
|
|
558
|
+
|
|
559
|
+
# Re-attest and update hash after human approval of intentional modifications
|
|
560
|
+
.\bapedge.exe pin update skill:deploy
|
|
561
|
+
|
|
562
|
+
# Re-attest all pinned assets across the workspace
|
|
563
|
+
.\bapedge.exe pin update --all
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
#### 3. Intelligent Auto-Sweep & Concurrency Guard
|
|
567
|
+
- `bapedge status` automatically detects pending offline audit entries in `.bapstate/audit.jsonl` and triggers an immediate sweep & flush to the control plane.
|
|
568
|
+
- **Concurrency Guard**: If `bap-daemon` or another `bap-edge` executor is actively running and responsive, `bapedge status` defers the sync so as not to contend with active spooling—unless that instance is dead or unresponsive, in which case it performs crash recovery.
|
|
569
|
+
|
|
570
|
+
#### 4. Robust AST Command Parsing & Canonical Symlink Resolution (BAP-533)
|
|
571
|
+
Standard string-splitting and regex decomposers are notoriously susceptible to command obfuscation, subshell embedding, directory traversal, and symlink evasion. `bap-edge` incorporates a pure Go shell grammar AST tokenizer and canonical path resolver:
|
|
572
|
+
- **Compound Pipeline Decomposition**: Parses operators (`&&`, `||`, `;`, `&`, `|`) into distinct atomic execution nodes.
|
|
573
|
+
- **Recursive Subshell Parsing**: Automatically extracts and evaluates embedded command substitutions (`$(curl ...)` and `` `...` ``) before any command runs.
|
|
574
|
+
- **Canonical Symlink Resolution**: Resolves all path arguments and I/O redirection targets (`>`, `>>`, `<`) via `filepath.Clean` and `filepath.EvalSymlinks` to their real filesystem destinations. Accessing sensitive files (`.env`, `~/.ssh`, `~/.aws`, `/etc/shadow`) through symlinks or relative traversal (`/app/subdir/../.env`) is evaluated against the target path and blocked.
|
|
575
|
+
- **Fail-Closed Pipeline Gating**: In compound pipelines (e.g. `git status && curl untrusted.site`), each node is evaluated independently against Cedar policy. If **any** sub-command, subshell, or redirected path violates security policy, the entire pipeline is denied immediately—preventing execution of any part of the command.
|
|
576
|
+
|
|
577
|
+
#### 5. Process-Level Supervision & Child Ancestry Tracking (BAP-534)
|
|
578
|
+
Subprocesses spawned by permitted parent commands (e.g., `npm`, `make`, `python`) are cryptographically and structurally governed:
|
|
579
|
+
- **Cryptographic Ancestry**: Every tool execution records complete process ancestry (`parent:<pid>`, `broker:<pid>`, `child:<pid>`) inside `ExecutionReceipt` and audit log entries.
|
|
580
|
+
- **Windows Job Object Containment**: Child processes are assigned to a Windows Job Object with `JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE`, ensuring any unapproved child processes cannot outlive or escape the broker's process boundary.
|
|
581
|
+
|
|
582
|
+
#### 6. Ambient Credential Shielding & Secret Redaction (BAP-535)
|
|
583
|
+
Protects standing developer secrets from ambient exposure and exfiltration:
|
|
584
|
+
- **Ambient Secret Stripping**: All child processes executed under `bapedge exec` or launcher sessions have standing credentials scrubbed from the environment (`AWS_*`, `GITHUB_*`, `OPENAI_*`, `ANTHROPIC_*`, `SLACK_*`, `AZURE_*`, and sensitive suffixes `*_TOKEN`, `*_KEY`, `*_SECRET`, `*_PASSWORD`).
|
|
585
|
+
- **Output Stream Redaction**: Detects and redacts private keys (`BEGIN ... PRIVATE KEY`), AWS access keys (`AKIA...`), GitHub tokens (`ghp_...`), OpenAI keys (`sk-...`), and Bearer JWT tokens in stdout/stderr with `[BAP_REDACTED_*]` tags.
|
|
586
|
+
|
|
587
|
+
#### 7. Incident Forensics & Automated Snapshot Rollback (BAP-538)
|
|
588
|
+
Provides point-in-time recovery for files modified during agent execution:
|
|
589
|
+
- **Pre-Execution Checkpointing**: Files targeted by mutating commands or file redirection (`>`, `>>`) are automatically captured into `.bapstate/snapshots/<sessionID>/<ckptID>/` with SHA-256 hashes before execution occurs.
|
|
590
|
+
- **1-Click Rollback CLI**:
|
|
591
|
+
```powershell
|
|
592
|
+
# List checkpoints for a session
|
|
593
|
+
.\bapedge.exe rollback --session-id <session_id> --list --json
|
|
594
|
+
|
|
595
|
+
# Rollback a specific file or the entire session to safe baseline
|
|
596
|
+
.\bapedge.exe rollback --session-id <session_id> --file <target_file> --json
|
|
597
|
+
```
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
### 12. Unified CLI UX, Binary Consistency & Service Lifecycle (Epic 30 — `BAP-547`)
|
|
602
|
+
|
|
603
|
+
BAP provides an identical, cohesive command-line interface across all four production binaries (`bapedge`, `bapcontrolplane`, `bapgateway`, `bapmcp`):
|
|
604
|
+
|
|
605
|
+
#### 1. Universal Command Matrix
|
|
606
|
+
|
|
607
|
+
| Subcommand | `bapedge` | `bapcontrolplane` | `bapgateway` | `bapmcp` | Description |
|
|
608
|
+
|---|:---:|:---:|:---:|:---:|---|
|
|
609
|
+
| `start` | ✅ | ✅ | ✅ | — | Start component server / supervisor (supports `--detach` / `-d`, `--port`) |
|
|
610
|
+
| `stop` | ✅ | ✅ | ✅ | — | Gracefully terminate running instance and cleanup PID files |
|
|
611
|
+
| `status` | ✅ | ✅ | ✅ | ✅ | Query health, active port, uptime, and database persistence |
|
|
612
|
+
| `restart` | ✅ | ✅ | ✅ | — | Atomic restart (`stop` $\to$ wait $\to$ `start`) |
|
|
613
|
+
| `enable` | ✅ | ✅ | ✅ | — | Idempotent workstation/service initialization (setup tokens & state) |
|
|
614
|
+
| `serve` | ✅ | ✅ | ✅ | ✅ | Explicit foreground server execution alias |
|
|
615
|
+
| `trust` | ✅ | — | — | — | Authorize cross-folder mutations (`--session`, `--project`, `--global`) |
|
|
616
|
+
| `untrust` | ✅ | — | — | — | Revoke cross-folder mutation authorization |
|
|
617
|
+
| `permissions` | ✅ | — | — | — | List all active authorizations across all scopes |
|
|
618
|
+
| `rollback` | ✅ | — | — | — | Forensically revert file mutations to pre-execution checkpoints |
|
|
619
|
+
| `pin` | ✅ | — | — | — | Cryptographically pin, verify, and re-attest skills, prompts & tools |
|
|
620
|
+
| `why` | ✅ | — | — | — | Instant terminal explanation of Cedar policy decisions |
|
|
621
|
+
| `exec` / `check` | ✅ | — | — | — | Governed execution / dry-run evaluation under kernel isolation |
|
|
622
|
+
| `mcp` | ✅ | — | — | ✅ | Model Context Protocol JSON-RPC stdio server |
|
|
623
|
+
|
|
624
|
+
#### 2. Building All BAP Binaries
|
|
625
|
+
Compile zero-dependency static binaries and deploy across the workspace:
|
|
626
|
+
```powershell
|
|
627
|
+
# 1. Build Central Control Plane
|
|
628
|
+
cd bap-controlplane; go build -o bapcontrolplane.exe ./cmd/server; cd ..
|
|
629
|
+
|
|
630
|
+
# 2. Build Zero-Trust Gateway PEP
|
|
631
|
+
cd bap-gateway; go build -o bapgateway.exe .; cd ..
|
|
632
|
+
|
|
633
|
+
# 3. Build Edge Local Trusted Daemon (LTD) & MCP Broker
|
|
634
|
+
cd bap-edge; go build -o bapedge.exe .; cd ..
|
|
635
|
+
|
|
636
|
+
# 4. Deploy binaries to workspace root and dist/
|
|
637
|
+
powershell -ExecutionPolicy Bypass -File update_binaries.ps1
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
#### 3. Command Line Parameters Reference
|
|
641
|
+
|
|
642
|
+
##### A. `bapcontrolplane` (Central Policy Authority)
|
|
643
|
+
```powershell
|
|
644
|
+
# Display help and usage banner (default when no parameters provided)
|
|
645
|
+
.\bapcontrolplane.exe
|
|
646
|
+
|
|
647
|
+
# Start server in foreground
|
|
648
|
+
.\bapcontrolplane.exe start --port 8080 --mode dev --db bap-controlplane.db
|
|
649
|
+
|
|
650
|
+
# Start server as detached background daemon
|
|
651
|
+
.\bapcontrolplane.exe start --detach --port 8080
|
|
652
|
+
|
|
653
|
+
# Query running control plane status, port, uptime, and state stores
|
|
654
|
+
.\bapcontrolplane.exe status
|
|
655
|
+
|
|
656
|
+
# Gracefully terminate running control plane
|
|
657
|
+
.\bapcontrolplane.exe stop
|
|
658
|
+
|
|
659
|
+
# Restart running control plane
|
|
660
|
+
.\bapcontrolplane.exe restart --port 8080
|
|
661
|
+
|
|
662
|
+
# Initialize admin tokens (.bap-admin-token) and state directories
|
|
663
|
+
.\bapcontrolplane.exe enable
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
**Common Flags:**
|
|
667
|
+
- `--port <p>`: Port for HTTP server (default: `8080` or `$PORT`, `$BAP_PORT`)
|
|
668
|
+
- `--detach`, `-d`: Spawn as background process
|
|
669
|
+
- `--mode <dev|prod>`: Environment mode (`dev` for open OTC, `prod` for enterprise OIDC)
|
|
670
|
+
- `--db <path>`: SQLite database file (default: `bap-controlplane.db`, or `:memory:`)
|
|
671
|
+
- `--secret <key>`: HMAC signing secret for JWT grants (or `$BAP_SECRET_KEY`)
|
|
672
|
+
- `--admin-token <token>`: Administrative bearer token (persisted in `.bap-admin-token`)
|
|
673
|
+
- `--tls`, `--https`: Enable HTTPS with auto-generated dev certificates
|
|
674
|
+
- `--policy <path>`: Path to authoritative Cedar policy file
|
|
675
|
+
|
|
676
|
+
##### B. `bapgateway` (Zero-Trust Policy Enforcement Point - PEP)
|
|
677
|
+
```powershell
|
|
678
|
+
# Display usage banner
|
|
679
|
+
.\bapgateway.exe
|
|
680
|
+
|
|
681
|
+
# Start Gateway PEP in foreground
|
|
682
|
+
.\bapgateway.exe start --port 9090 --controlplane http://localhost:8080
|
|
683
|
+
|
|
684
|
+
# Start Gateway PEP in background
|
|
685
|
+
.\bapgateway.exe start --detach --port 9090
|
|
686
|
+
|
|
687
|
+
# Query live status and upstream control plane connectivity
|
|
688
|
+
.\bapgateway.exe status
|
|
689
|
+
|
|
690
|
+
# Stop Gateway PEP
|
|
691
|
+
.\bapgateway.exe stop
|
|
692
|
+
|
|
693
|
+
# Restart Gateway PEP
|
|
694
|
+
.\bapgateway.exe restart
|
|
695
|
+
|
|
696
|
+
# Validate upstream connectivity and credentials
|
|
697
|
+
.\bapgateway.exe enable
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
**Common Flags:**
|
|
701
|
+
- `--port <p>`: Port for Gateway HTTP server (default: `9090` or `$BAP_GATEWAY_PORT`)
|
|
702
|
+
- `--detach`, `-d`: Spawn as background process
|
|
703
|
+
- `--controlplane <url>`: Central BAP Control Plane base URL (default: `http://localhost:8080`)
|
|
704
|
+
- `--secret <key>`: HMAC secret key for offline JWT verification
|
|
705
|
+
- `--consume`: Atomically consume single-use grants via control plane (default: `true`)
|
|
706
|
+
|
|
707
|
+
##### C. `bapedge` (Edge Local Trusted Daemon & Execution Broker)
|
|
708
|
+
```powershell
|
|
709
|
+
# Service Lifecycle
|
|
710
|
+
.\bapedge.exe start [--foreground] # Start supervisor daemon
|
|
711
|
+
.\bapedge.exe stop # Stop supervisor daemon
|
|
712
|
+
.\bapedge.exe restart # Restart supervisor daemon
|
|
713
|
+
.\bapedge.exe status # Inspect active sessions, policy cache, spool
|
|
714
|
+
.\bapedge.exe enable # 1-click developer setup
|
|
715
|
+
|
|
716
|
+
# Zero-Trust Governance & HITL Authorization
|
|
717
|
+
.\bapedge.exe trust --path <dir> [--scope session|project|global] [--ops write,delete]
|
|
718
|
+
.\bapedge.exe untrust --path <dir>
|
|
719
|
+
.\bapedge.exe permissions # List active cross-folder authorizations
|
|
720
|
+
.\bapedge.exe why "<command>" # Explain Cedar policy decision
|
|
721
|
+
.\bapedge.exe rollback --checkpoint-id <id> # Forensically restore mutated files
|
|
722
|
+
|
|
723
|
+
# Cryptographic Content Pinning (AIR Attestation & Agent Scoping)
|
|
724
|
+
.\bapedge.exe pin list # List pinned assets with AgentScope
|
|
725
|
+
.\bapedge.exe pin verify [--scope <agent>] # Verify skills/prompts for specific agent
|
|
726
|
+
.\bapedge.exe pin add <path> [--scope <ag>] # Pin asset with explicit agent scope
|
|
727
|
+
.\bapedge.exe pin update <id> [--all] # Re-attest approved modification
|
|
728
|
+
.\bapedge.exe pin unpin <id> [--all] # Unpin specific asset or all assets
|
|
729
|
+
.\bapedge.exe pin clear # Clear manifest to start fresh
|
|
730
|
+
.\bapedge.exe pin reset # Reset & auto-discover workspace assets
|
|
731
|
+
|
|
732
|
+
# Fleet Resilience, Sweep & Disconnected Sync
|
|
733
|
+
.\bapedge.exe sweep [--force] # Clean dead sessions, purge dead PIDs & shims
|
|
734
|
+
.\bapedge.exe sync [--server <url>] # Sync policy cache & flush offline audit spool
|
|
735
|
+
|
|
736
|
+
# Governed Execution
|
|
737
|
+
.\bapedge.exe exec "<command>" # Execute under kernel isolation
|
|
738
|
+
.\bapedge.exe check "<command>" # Policy evaluation only (zero side-effects)
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
##### D. `bapmcp` (Model Context Protocol Server)
|
|
742
|
+
```powershell
|
|
743
|
+
# Interactive mode in terminal: displays MCP onboarding and configuration guide
|
|
744
|
+
.\bapmcp.exe
|
|
745
|
+
|
|
746
|
+
# Start JSON-RPC 2.0 stdio transport (default when spawned by Claude Code / Cursor)
|
|
747
|
+
.\bapmcp.exe --stdio
|
|
748
|
+
|
|
749
|
+
# Query MCP tool configuration and policy status
|
|
750
|
+
.\bapmcp.exe status
|
|
751
|
+
```
|
|
752
|
+
|
|
753
|
+
**Exposed MCP Tools:**
|
|
754
|
+
- `bap_execute`: Governed shell execution within sandboxed kernel isolation.
|
|
755
|
+
- `bap_explain_policy`: Zero-trust Cedar decision query and explanation.
|
|
756
|
+
- `bap_status`: Real-time inspection of local sessions, daemon health, and policy cache.
|
|
757
|
+
|
|
758
|
+
---
|
|
759
|
+
|
|
760
|
+
## 📂 Repository Structure
|
|
761
|
+
|
|
762
|
+
| Path | Purpose & Capabilities |
|
|
763
|
+
|---|---|
|
|
764
|
+
| [`bap-controlplane/`](file:///c:/Users/User/pyprj/bapltd/bap-controlplane/) | Central policy master, grant minter, atomic state burner, SQLite Merkle hash chain, and REST APIs. |
|
|
765
|
+
| [`bap-gateway/`](file:///c:/Users/User/pyprj/bapltd/bap-gateway/) | Resource-side Zero-Trust Gateway PEP with Envoy/Istio `ext_authz` semantics and `deriveOperation`. |
|
|
766
|
+
| [`bap-edge/`](file:///c:/Users/User/pyprj/bapltd/bap-edge/) | Local trusted broker with in-process Cedar engine (<1.5ms), policy cache, and offline fail-secure core. |
|
|
767
|
+
| [`cchook/`](file:///c:/Users/User/pyprj/bapltd/cchook/) | Managed Claude Code hooks (`SessionStart`, `UserPromptSubmit`, `PreToolUse`) with offline classifier. |
|
|
768
|
+
| [`copilot/`](file:///c:/Users/User/pyprj/bapltd/copilot/) | GitHub Copilot adapter wrapping `bapedge exec` with standard mission context. |
|
|
769
|
+
| [`python-agent/`](file:///c:/Users/User/pyprj/bapltd/python-agent/) | BAP Python SDK (`BAPSession`) and sample governed worker agents. |
|
|
770
|
+
| [`dist/windows-amd64/`](file:///c:/Users/User/pyprj/bapltd/dist/windows-amd64/) | Precompiled production Go binaries (`bapcontrolplane`, `bapgateway`, `bapedge`, `interceptor`, `copilot-interceptor`). |
|
|
771
|
+
| [`tests/`](file:///c:/Users/User/pyprj/bapltd/tests/) | Full test suites: 10-point adversarial matrix, 3,000-agent load tests, 50k perf benchmarks, and executor tests. |
|
|
772
|
+
|
|
773
|
+
---
|
|
774
|
+
|
|
775
|
+
## 🎯 One-Sentence Summary
|
|
776
|
+
|
|
777
|
+
**BAP gives every AI agent its own identity and only the authority it needs, when it needs it, while preserving human delegation and proving evidence across the entire lifecycle.**
|