Skip to content

docs, examples: add Private DIY Enterprise Stack example and embedded live workbench - #804

Merged
aojea merged 1 commit into
google:mainfrom
aojea:docs/private-diy-stack
Oct 22, 2026
Merged

aojea merged 1 commit into
google:mainfrom
aojea:docs/private-diy-stack

Conversation

@aojea

@aojea aojea commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a runnable end-to-end Private DIY Enterprise Stack (Safely On-Premises & in Cloud) example (development/examples/private-diy-stack/), a 1080p 3D Live-Execution Architectural Walkthrough video (site/static/demo-private-diy-stack.mp4) rendered from a live run of the Agent Mesh Go binaries (render_3d_video.py), and a use-case guide (site/content/docs/use-cases/private-diy-stack.md) demonstrating how enterprises can run a zero-trust AI workforce safely across on-premises infrastructure and cloud (Cloud Run, GKE, or local servers) without site-to-site VPNs, inbound firewall holes, or raw credentials inside agent containers:

  1. Open-Weights Reasoning (inference://private-llm): Gemma 3 / deepseek-r1:1.5b served via Ollama, vLLM (on Cloud Run GPU, GKE, or on-prem GPUs), or the built-in OpenAI-compatible engine (backends.py).
  2. Self-Hosted Agent Harness (agent_harness.py): A zero-dependency Python ReAct harness that holds zero database credentials, zero API keys, and zero network routing logic—communicating strictly with its local agentmesh-node sidecar over 127.0.0.1:19101/mcp and 127.0.0.1:19101/v1.
  3. Agent Mesh Sidecar Networking & Zero-Trust Policy Across On-Prem & Cloud (agentmesh-one + agentmesh-node):
    • Act 1 (Sidecar Node Architecture): Enrolls node-tools.yaml (On-Prem Vault zone), node-inference.yaml (Cloud / On-Prem GPU zone), and node-agent.yaml (Cloud Run / Workstation zone) and discovers mcp://erp-db, egress://compliance.internal, and inference://private-llm over Kademlia DHT / GossipSub.
    • Act 2 (End-to-End Hybrid Execution): Runs agent_harness.py to audit an ERP invoice (INV-2026-089), check warehouse stock (SKU-GPU-H200), and verify vendor compliance (ACME-01) with node-side secret brokering (secrets/compliance-api-key) so on-prem secrets never leave the vault node.
    • Act 3 (Zero-Trust Identity & Default-Deny Policy):
      • 3a: Blocks unpermitted service names (mcp://payroll-vault) hosted on the same Vault node (biscuit: denied by no matching policies).
      • 3b: Blocks unpermitted HTTP mutations (POST /v1/vendors/ACME-01 -> HTTP 403).
      • 3c: Enforces positive Datalog label checks (check if label("residency", "on-prem"); and check if label("dept", "finance");), rejecting callers from dept=external.
      • 3d: Mints a per-task sealed Biscuit (tar_block) via RFC 8693 POST /oauth/token narrowed to read-only tools (lookup_invoice, check_inventory), blocking prompt-injected execute_wire_transfer calls before they reach SQLite.
    • Act 4 (Correlated Audit Trail & Kill-Switch): Summarizes ALLOW / DENY decisions across sidecars (audit.py) and revokes the unauthorized external peer mesh-wide via agentmesh-one admin ban.

3D Live-Execution Walkthrough & Local Browser Workbench

  • 1080p 3D Live-Execution Video (site/static/demo-private-diy-stack.mp4): Embedded at the top of /docs/use-cases/private-diy-stack/. Generated by render_3d_video.py (make -C development/examples/private-diy-stack record), which boots the real agentmesh-one control plane and four agentmesh-node sidecars, executes all 4 acts against the live Go binaries, and renders a 1920x1080 30fps 3D perspective architectural animation synchronized with the real Peer IDs, SQLite outputs, Biscuit Datalog denials, and audit logs.
  • Live Local Browser Workbench (dashboard.py): Launching make -C development/examples/private-diy-stack ui starts a live local web workbench on http://127.0.0.1:18899 backed directly by the running agentmesh-one and agentmesh-node processes.

Verification

  • make -C development/examples/private-diy-stack run (runs all 4 acts headlessly in ~12s)
  • make -C development/examples/private-diy-stack ui (launches the live local browser workbench on http://127.0.0.1:18899)
  • make -C development/examples/private-diy-stack record (re-records the 1080p 3D live-execution walkthrough site/static/demo-private-diy-stack.mp4)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the Private DIY Enterprise Stack example, which demonstrates an air-gapped, zero-trust AI workforce using self-hosted reasoning models, an agent harness, and Agent Mesh sidecars. The feedback highlights several reliability and robustness issues across the newly added scripts: resource leaks (unclosed files in dashboard.py and unclosed SQLite connections), potential crashes (an IndexError on empty catalog lines and a sqlite3.OperationalError during database initialization), a violation of Section 6.3 of the style guide regarding swallowed exceptions in backends.py, and a lack of error handling in run.sh if peer discovery fails.

Comment on lines +258 to +286
for raw_line in open(p, errors="replace"):
line = raw_line.rstrip("\n")
m = audit_re.search(line)
if m:
try:
d = json.loads(m.group(1))
except json.JSONDecodeError:
continue
who = f"{d.get('role') or '-'} ({d.get('peer_id', '')[:12]}…)"
what = " ".join(x for x in (d.get("method"), d.get("path")) if x) or d.get("protocol", "-")
events.append(
{
"decision": d.get("decision", "?").upper(),
"caller": who,
"method": what,
"service": d.get("target", "-"),
}
)
continue
tm = tar_re.search(line)
if tm:
events.append(
{
"decision": "DENY",
"caller": f"tar_block ({tm.group(2)})",
"method": f"tools/call {tm.group(1)}",
"service": "mcp://erp-db",
}
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

In parse_audit_events, the log files are opened using open(p, errors="replace") inside a loop without being explicitly closed or wrapped in a with statement. Since parse_audit_events is called on every /api/state request (which is polled frequently), this will quickly leak file descriptors and can lead to resource exhaustion (e.g., "Too many open files" error).

            with open(p, errors="replace") as f:\n                for raw_line in f:\n                    line = raw_line.rstrip("\\n")\n                    m = audit_re.search(line)\n                    if m:\n                        try:\n                            d = json.loads(m.group(1))\n                        except json.JSONDecodeError:\n                            continue\n                        who = f"{d.get('role') or '-'} ({d.get('peer_id', '')[:12]}…)"\n                        what = " ".join(x for x in (d.get("method"), d.get("path")) if x) or d.get("protocol", "-")\n                        events.append(\n                            {\n                                "decision": d.get("decision", "?").upper(),\n                                "caller": who,\n                                "method": what,\n                                "service": d.get("target", "-"),\n                            }\n                        )\n                        continue\n                    tm = tar_re.search(line)\n                    if tm:\n                        events.append(\n                            {\n                                "decision": "DENY",\n                                "caller": f"tar_block ({tm.group(2)})",\n                                "method": f"tools/call {tm.group(1)}",\n                                "service": "mcp://erp-db",\n                            }\n                        )

Comment on lines +345 to +348
with urllib.request.urlopen(req, timeout=8) as resp:
return resp.read()
except Exception:
return None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

According to the Repository Style Guide Section 6.3, errors should not be silently swallowed. In _try_upstream, any exception raised during the connection to the upstream Ollama server is caught and silently ignored by returning None. This makes it extremely difficult for operators to diagnose connection or configuration issues. Please log or print the exception before returning None.

            with urllib.request.urlopen(req, timeout=8) as resp:\n                return resp.read()\n        except Exception as e:\n            print(f"Upstream request failed: {e}", flush=True)\n            return None
References
  1. Section 6.3: Errors are not swallowed. Any exception caught during runtime operations should be logged or printed to ensure auditability.

Comment on lines +418 to +419
raw_catalog = sidecar.call_sidecar_tool("find_remote_tools", {"service_name": "erp-db"})
catalog = json.loads(raw_catalog.splitlines()[-1])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If raw_catalog is empty (e.g., if the tool call returns no content or fails), raw_catalog.splitlines() will be an empty list, and accessing [-1] will raise an IndexError, crashing the dashboard server. Please check if the list is non-empty before accessing the last element.

            raw_catalog = sidecar.call_sidecar_tool("find_remote_tools", {"service_name": "erp-db"})\n            lines = raw_catalog.splitlines()\n            if not lines:\n                return self._send_json({"error": "No tools discovered"}, status=500)\n            catalog = json.loads(lines[-1])

Comment on lines +290 to +296
if not os.path.exists(self.db_path):
return {"invoices_count": 0, "wire_transfers_count": 0}
conn = sqlite3.connect(self.db_path)
inv = conn.execute("SELECT COUNT(*) FROM invoices").fetchone()[0]
wires = conn.execute("SELECT COUNT(*) FROM wire_transfers").fetchone()[0]
conn.close()
return {"invoices_count": inv, "wire_transfers_count": wires}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the SQLite database file exists but the tables (invoices or wire_transfers) have not been fully initialized yet by backends.py, conn.execute will raise a sqlite3.OperationalError. Since this method is called on every /api/state request, it can crash the dashboard. Additionally, if an exception is raised, conn.close() is bypassed, leaking the connection. Please wrap the execution in a try...except block and ensure the connection is closed.

        if not os.path.exists(self.db_path):\n            return {"invoices_count": 0, "wire_transfers_count": 0}\n        conn = None\n        try:\n            conn = sqlite3.connect(self.db_path)\n            inv = conn.execute("SELECT COUNT(*) FROM invoices").fetchone()[0]\n            wires = conn.execute("SELECT COUNT(*) FROM wire_transfers").fetchone()[0]\n            return {"invoices_count": inv, "wire_transfers_count": wires}\n        except sqlite3.Error:\n            return {"invoices_count": 0, "wire_transfers_count": 0}\n        finally:\n            if conn:\n                conn.close()

Comment on lines +204 to +208
if [[ -n "${VAULT_PEER}" && -n "${GPU_PEER}" ]]; then
break
fi
sleep 0.5
done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If the discovery loop finishes without successfully finding VAULT_PEER or GPU_PEER, the script will continue with empty variables, leading to silent failures or cryptic errors in subsequent acts. Please verify that both peer IDs were successfully discovered and exit with an error if they are empty.

Suggested change
if [[ -n "${VAULT_PEER}" && -n "${GPU_PEER}" ]]; then
break
fi
sleep 0.5
done
if [[ -n "${VAULT_PEER}" && -n "${GPU_PEER}" ]]; then\n break\n fi\n sleep 0.5\ndone\n\nif [[ -z "${VAULT_PEER}" || -z "${GPU_PEER}" ]]; then\n echo "Error: Failed to discover Vault Peer or GPU Peer within timeout." >&2\n exit 1\nfi

@aojea
aojea force-pushed the docs/private-diy-stack branch 3 times, most recently from 870a0e1 to 0afecec Compare October 21, 2026 14:52
@aojea
aojea force-pushed the docs/private-diy-stack branch from 0afecec to f4f85e9 Compare October 21, 2026 17:33
@aojea
aojea merged commit 7af0e2d into google:main Oct 22, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant