Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(hcc): add public census wrapper with a static context placeholder
Alfredo Lopez3a309a9942f5
diff --git a/scripts/ops/hcc-netpol-orphan-census-clerum-dev.sh b/scripts/ops/hcc-netpol-orphan-census-clerum-dev.shnew file mode 100755index 000000000..ba01ecf18--- /dev/null+++ b/scripts/ops/hcc-netpol-orphan-census-clerum-dev.sh@@ -0,0 +1,25 @@+#!/bin/bash+# Public entry point for the HCC NetworkPolicy orphan census.+#+# k8s-context-guard-v2 requires a static context name in this file.+# The token below is the sanctioned public placeholder used by every other+# script in this repo. The live GKE project/cluster name is not committed+# here — leak-guards forbid it. Supply the real context from evenfire-infra+# or a local kubeconfig alias, never from this tree.+#+# kubectl --context=gke_your-gcp-project_us-central1-a_example-dev+#+# Classification lives in hcc-netpol-orphan-census.sh. Do not duplicate it.+# Feeds #478 (census series) and #484 (census↔controller parity).+#+# Usage:+# ./scripts/ops/hcc-netpol-orphan-census-clerum-dev.sh++set -euo pipefail+umask 077++CONTEXT=gke_your-gcp-project_us-central1-a_example-dev+export CONTEXT++ROOT="$(cd "$(dirname "$0")" && pwd)"+exec "${ROOT}/hcc-netpol-orphan-census.sh"diff --git a/scripts/ops/hcc-netpol-orphan-census.sh b/scripts/ops/hcc-netpol-orphan-census.shindex 9c99b5b3f..2e3b81632 100755--- a/scripts/ops/hcc-netpol-orphan-census.sh+++ b/scripts/ops/hcc-netpol-orphan-census.sh@@ -31,6 +31,13 @@# reserved-name repairable approximation, not the controller's current# pass authority gate.#+# Cap formula must stay aligned with evaluateNetPolOrphanSweepCap in+# host-context-controller/src/networkPolicyReconciler.ts and the compiled+# defaults in host-context-controller/src/config.ts (absolute 10, percent+# 20, rpc-proxy namespace). If you change either side, change this script.+# Typed membership requires clerum.io/managed-by=host-context-controller+# so a foreign-owned typed policy cannot inflate listed/orphans (#484).+## Double-samples 90s apart. Adjudicates only when the desired Context +# McpServer identity set is identical across samples; otherwise# INCONCLUSIVE_RERUN. A sample that listed zero managed policies is@@ -61,7 +68,7 @@ deployment_env() {local key="$1"local valuelocal rc=0- value="$(kc -n "${HCC_NS}" get deploy "${HCC_DEPLOYMENT}" -o "jsonpath={.spec.template.spec.containers[0].env[?(@.name==\"${key}\")].value}")" || rc=$?+ value="$(kc -n "${HCC_NS}" get deployments "${HCC_DEPLOYMENT}" -o "jsonpath={.spec.template.spec.containers[0].env[?(@.name==\"${key}\")].value}")" || rc=$?if [[ "${rc}" -ne 0 ]]; thenecho "[census] FATAL: kubectl failed reading ${key} from ${HCC_NS}/${HCC_DEPLOYMENT} (exit ${rc})" >&2exit 2@@ -106,14 +113,30 @@ if [[ "${RPC_NS}" == "UNSET" ]]; thenRPC_NS="${COMPILED_RPC_NS_DEFAULT}"fi+# Fail loud on a missing namespace. An empty list from a typo must never+# print VERDICT=CLEAN (zero-tests-is-never-success).+require_namespace() {+ local ns="$1"+ if ! kc get namespaces "${ns}" -o name >/dev/null; then+ echo "[census] FATAL: namespace ${ns} does not exist; refusing to sample an empty inventory" >&2+ exit 2+ fi+}+require_namespace "${MAPPER_NS}"+require_namespace "${HOST_NS}"+require_namespace "${RPC_NS}"+# Typed policy-type membership, plus the reserved-name repairable class# (managed-by present, policy-type absent). Shared by listed + orphan filters.CENSUS_MANAGED_JQ='def policy_type: .metadata.labels["clerum.io/policy-type"];def is_typed:- policy_type == "context-allow"- or policy_type == "rpc-proxy-egress"- or policy_type == "external-egress";+ .metadata.labels["clerum.io/managed-by"] == "host-context-controller"+ and (+ policy_type == "context-allow"+ or policy_type == "rpc-proxy-egress"+ or policy_type == "external-egress"+ );def is_untyped_repairable:.metadata.labels["clerum.io/managed-by"] == "host-context-controller"and (policy_type == null)