Agent Governance Stack Implementation Plan (2026-11-06)#
For agentic workers: this is the sanitized public copy of the overnight run plan. Steps use checkbox syntax for tracking. work strictly top-down through S1…S5. Each stack has a GATE. Do not start stack N+1 until every GATE line of stack N is green and logged in the Run Log. Nothing is pushed to GitHub tonight. If a GATE cannot be made green after two honest attempts, stop, write the Morning Report, and end.
Goal: Finish porting the governance best practices of the private reference governance repository into this repository as a verified, locally-stacked set of branches: hygiene gate (S1), governance IaC + agents (S2), shell test harnesses + CI (S3), documentation (S4), live Gemini Enterprise binding and publication (S5).
Architecture: Five branches, each stacked on the previous, each in its own worktree under agentic_soc_agentspace__worktrees/. S1 and S2 already exist as commits and only need re-verification. S3…S5 are new. Terraform local state is the single live source of truth and moves with the newest stack that runs apply.
Tech Stack: Python 3.12 (uv venv), just, bash + shellcheck 0.10, Terraform 1.16.5 with google-beta ~> 8.7, ADK 2.13.0 / a2a-sdk 1.3.0, GitHub Actions, gh CLI (read-only tonight).
Spec / references:
Upstream reference clone:
<REFERENCE_REPO_ROOT>(HEADb7c5a6e, no drift since port)
Global Constraints#
PUBLIC repository. Every commit must pass
scripts/check_public_repo_hygiene.py --git-range origin/main..HEADwith 0 findings. Never write internal sandbox or corporate domain names, internal shortlinks, tenant IDs, project numbers, engine IDs, or customer IDs into tracked files (the gate’s rule list inscripts/check_public_repo_hygiene.pyis authoritative). Use placeholders (<PROJECT_ID>,<GE_ENGINE_ID>).No emojis anywhere (code, docs, commit messages).
tests/test_governed_agents.py::test_zero_emojis_across_governance_filesenforces this for governance files.git add <explicit paths>only. Nevergit add ./-A. Never stage.env,.envrc,*.tfvars,*.tfstate*,.gcloud/.Branch names use
__as delimiter, never/.Pin every
pip installin CI (pkg==x.y.z). Pin GitHub Actions to major tags already used in the repo (actions/checkout@v5,actions/setup-python@v6,actions/cache@v5).Shell examples in docs: define variables first, then reference them (
PROJECT_ID="..."then$PROJECT_ID).Do NOT push, do NOT open PRs, do NOT merge. Local stack only.
Do NOT destroy or scale down any resource in
<PROJECT_ID>or<REFERENCE_SANDBOX_PROJECT>.Run pytest as
.venv/bin/python -m pytest -o addopts="" -p no:cacheprovider <files>(repoaddoptsrequirespytest-cov, which is not in the venv).Commit messages: imperative,
<type>(<scope>): <summary>matching repo history (security:,test(governance):,docs(governance):,feat(governance):,ci(governance):).
Stack Layout#
flowchart LR
M["origin/main 112e9b5"] --> S1["S1 security__public-repo-secret-gates 1f9e7bd (exists)"]
S1 --> S2["S2 governance__terraform-and-a2a-agents 5404f96 (exists)"]
S2 --> S3["S3 governance__shell-tests-and-ci (new)"]
S3 --> S4["S4 governance__docs (new)"]
S4 --> S5["S5 governance__ge-binding (new)"]
Stack |
Worktree path (under |
Branch |
Base |
|---|---|---|---|
S1 |
|
|
|
S2 |
|
|
S1 |
S3 |
|
|
S2 |
S4 |
|
|
S3 |
S5 |
|
|
S4 |
Stacking rule: if you amend or add commits to a lower stack after a higher one exists, rebase every higher stack with git rebase --onto <lower-new-head> <lower-old-head> <higher-branch> and re-run that stack’s GATE. Avoid this by finishing each stack before creating the next.
Pre-flight (15 min)#
cd $S2 && git status --shortis empty;git -C $WT/main fetch originand confirmgit log --oneline HEAD..origin/main | wc -lis0in S2 (still rebased on current main). If main moved, rebase S1 then S2 ontoorigin/mainand re-run both GATES.direnv exec $S2 gcloud auth application-default print-access-token >/dev/null && echo ADC_OK(if this fails, stop: credentials must be refreshed by the user withgcloud auth login <ACCOUNT> --update-adcfrom inside the direnv directory).direnv exec $S2 terraform -chdir=terraform plan -input=false -lock-timeout=60s -detailed-exitcode -out=/tmp/preflight.tfplan; echo exit=$?Expected: exit0or2. If2,terraform show /tmp/preflight.tfplan | grep -E "^\s*[-~+] " | sort | uniq -cmust show no-(destroy) lines. Record in Run Log. Delete/tmp/preflight.tfplan.Snapshot the Gemini Enterprise app (
bash scripts/governance/bind_ge_app.sh status) and the current agent list (just gem-ent-list-agents) into your evidence directory before any binding change.
S1: security__public-repo-secret-gates (re-verify only, 10 min)#
Files: none to change. Commit 1f9e7bd already contains scripts/check_public_repo_hygiene.py, tests/test_check_public_repo_hygiene.py, .gitignore, .pre-commit-config.yaml, .github/workflows/public-repo-hygiene.yml, justfile, pyproject.toml.
cd $WT/security__public-repo-secret-gates && ln -sfn ../governance__terraform-and-a2a-agents/.venv .venvGATE S1-a:
.venv/bin/python -m pytest -o addopts="" -p no:cacheprovider tests/test_check_public_repo_hygiene.py->5 passedGATE S1-b:
python3 scripts/check_public_repo_hygiene.py --all-tracked; echo exit=$?->exit=0GATE S1-c:
python3 scripts/check_public_repo_hygiene.py --git-range origin/main..HEAD; echo exit=$?->exit=0GATE S1-d:
.venv/bin/python -m pre_commit run --files $(git diff --name-only origin/main..HEAD) 2>&1 | tail -20-> every hookPassedorSkipped. Ifpre_commitis not installed in the venv:uv pip install --python .venv/bin/python pre-commit==4.2.0.GATE S1-e:
git log --oneline origin/main..HEAD | wc -l->1;git status --short-> empty.Log S1 PASS.
S2: governance__terraform-and-a2a-agents (re-verify, 30 min incl. live smoke test)#
Files: none to change unless a GATE fails. Commit 5404f96.
cd $S2GATE S2-a:
.venv/bin/python -m pytest -o addopts="" -p no:cacheprovider tests/test_governed_agents.py tests/test_check_public_repo_hygiene.py->11 passedGATE S2-b:
.venv/bin/ruff check governed_agents scripts/governance tests/test_governed_agents.py->All checks passed!GATE S2-c:
python3 scripts/check_public_repo_hygiene.py --git-range origin/main..HEAD; echo exit=$?->exit=0GATE S2-d:
direnv exec . just governance-validate 2>&1 | tail -3->Success! The configuration is valid.(this also regeneratesterraform/dist/*.tar.gzandterraform/agentcards/*.json; afterwardsgit status --shortmust still be empty, proving card generation is deterministic. Ifterraform/agentcards/*.jsonchanged, that is a real finding: inspect, and if the generator is right, commit the regenerated cards withfix(governance): regenerate agent cardsand note it.)GATE S2-e (live):
direnv exec . just governance-smoke-test 2>&1 | tee $EVID/S2/smoke.txt | tail -8-> final summary5 passed, 0 failed(per-case timeout 300 s; total may take 10 to 15 min). If a single case fails on a timeout, rerun only that case once withjust governance-smoke-test case=<id>.GATE S2-f (live):
direnv exec . bash scripts/governance/verify_logs.sh unregistered --freshness 2h 2>&1 | tee $EVID/S2/unregistered.txt | tail -5-> zero unregistered egress hosts (noFATAL).GATE S2-g:
git status --shortempty;git log --oneline origin/main..HEAD | wc -l->2.Log S2 PASS.
S3: governance__shell-tests-and-ci (new, 3 to 4 h)#
Port the eight offline harnesses from the reference repo’s scripts/tests/ to scripts/governance/tests/, adapted to the five SecOps agents and to the divergent SecOps scripts; add shellcheck, a runner, a just recipe, Terraform formatting, and a GitHub Actions workflow.
Files:
Create:
scripts/governance/tests/run_all.shCreate:
scripts/governance/tests/package_agent_test.sh(port of upstreamscripts/tests/package_agent_test.sh, 206 lines)Create:
scripts/governance/tests/verify_logs_test.sh(upstream 231 lines; ourverify_logs.shhas 406 changed lines vs upstream, read ours first)Create:
scripts/governance/tests/auth_provider_test.sh(upstream 494 lines; ours has 394 changed lines, GTI API key instead of Maps)Create:
scripts/governance/tests/bind_ge_app_test.sh(upstream 224 lines)Create:
scripts/governance/tests/ge_agent_test.sh(upstream 329 lines)Create:
scripts/governance/tests/delete_until_gone_test.sh(upstream 154 lines)Create:
scripts/governance/tests/sgp_test.sh(upstream 277 lines, testssgp_gateway_config.sh)Modify:
tests/test_governed_agents.py(fold in any assertions from upstreamscripts/tests/orchestrator_notice_test.pynot already covered bytest_soc_orchestrator_policy_block_banners; upstreamprompt_probe.pyis a live probe, not ported, say so inrun_all.shheader)Modify:
scripts/governance/*.sh(only to clear shellcheck SC1010/SC2155 findings; no behavior change)Modify:
terraform/52-policies-access.tf(terraform fmtonly)Modify:
.pre-commit-config.yaml(add shellcheck hook)Modify:
justfile(addgovernance-test,governance-lint)Create:
.github/workflows/governance-ci.yml
Interfaces:
Produces:
bash scripts/governance/tests/run_all.shexits 0 and printsALL GREEN: <n> harnesses, <m> checkson success;just governance-testwraps it;just governance-lintruns shellcheck +terraform fmt -check. S4 docs reference these three commands by exact name.
Task 3.1: Create worktree#
cd $WT/main && git worktree add ../governance__shell-tests-and-ci -b governance__shell-tests-and-ci governance__terraform-and-a2a-agentscd $WT/governance__shell-tests-and-ci && ln -s ../governance__terraform-and-a2a-agents/.venv .venv && git status --short-> empty. SetS3=$PWD.
Task 3.2: Harness skeleton and runner (do this first so every later harness is runnable)#
Create
scripts/governance/tests/run_all.sh:#!/usr/bin/env bash # # Run every offline governance harness. No network, no credentials: each # harness stubs gcloud/terraform/curl on PATH. Ported from the reference # agent-governance repository's scripts/tests/, adapted to the five SecOps # agents. prompt_probe.py (live A2A probe) is intentionally not ported; use # scripts/governance/smoke_test.py for live verification. # # bash scripts/governance/tests/run_all.sh set -euo pipefail HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) readonly HERE harnesses=0; failures=0; checks=0 for t in "$HERE"/*_test.sh; do harnesses=$((harnesses + 1)) printf '== %s\n' "$(basename "$t")" if out=$(bash "$t" 2>&1); then printf '%s\n' "$out" else printf '%s\n' "$out"; failures=$((failures + 1)) fi checks=$((checks + $(printf '%s\n' "$out" | grep -c '^ ok ' || true))) done if (( failures > 0 )); then printf 'FAILED: %d of %d harnesses\n' "$failures" "$harnesses"; exit 1 fi printf 'ALL GREEN: %d harnesses, %d checks\n' "$harnesses" "$checks"
Run it:
bash scripts/governance/tests/run_all.sh->ALL GREEN: 0 harnesses, 0 checks(glob expands to literal when empty underset -u? It does not with nullglob unset: it will try to run a file named*_test.shand fail. Addshopt -s nullglobafterset -euo pipefail. Re-run; expectALL GREEN: 0 harnesses, 0 checks.)git add scripts/governance/tests/run_all.sh && git commit -m "test(governance): add offline harness runner"
Task 3.3: Port each harness (repeat this loop per file, in this order: package_agent, delete_until_gone, bind_ge_app, ge_agent, verify_logs, sgp, auth_provider)#
For each <name>:
Read the upstream harness
U=<REFERENCE_REPO_ROOT>/scripts/tests/<name>_test.shfully, and read OUR targetscripts/governance/<name>.shfully (ours diverges; the test must assert OUR behavior, not upstream’s).Copy upstream to
scripts/governance/tests/<name>_test.sh, then apply these mechanical edits:SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)stays (resolves toscripts/governance/).readonly REPO_ROOT="${SCRIPT_DIR%/scripts}"->readonly REPO_ROOT="${SCRIPT_DIR%/scripts/governance}".Any synthetic-repo layout that copies the script into
$WORK/scripts/must copy into$WORK/scripts/governance/and create agents under$WORK/governed_agents/<name>/(not$WORK/agents/).Agent names
iss,maps,orchestrator->cti_researcher,threat_hunter,detection_engineer,tier2_responder,soc_orchestrator(five, not three; assert count 5 where upstream asserts 3).mapstools.googleapis.com/ Maps API key -> the GTI host andagw-secops-gti-api-keyprovider name used in OURauth_provider.sh/20-authmanager.tf.Resource prefix
agw-iss->agw-secops; display strings “Astro Pizza” -> “Governed SecOps Orchestrator” (check OURge_agent.shfor the exact default).Remove or replace any upstream wording in comments that the hygiene gate rejects (internal sandbox names, internal shortlinks).
Run the single harness:
bash scripts/governance/tests/<name>_test.sh; echo exit=$?. Fix test expectations against OUR script’s real stdout/stderr strings (read the script; do not change the script to match upstream wording unless it is a genuine bug, in which case make a separatefix(governance):commit first).Negative check: temporarily break one assertion’s needle (e.g. append
XX), run again, confirm it reportsFAILand exits 1, then revert. This proves the harness can fail.bash scripts/governance/tests/run_all.sh | tail -1->ALL GREEN: <k> harnesses, ...withkincremented.git add scripts/governance/tests/<name>_test.sh && git commit -m "test(governance): port offline <name> harness for SecOps agents"
Specific guidance per harness:
package_agent_test.sh: two properties, files at archive root and byte-identical output across two runs. OURpackage_agent.shwritesterraform/dist/<name>.tar.gzand.sha256; the real-tree block at the end must iterate the 5 names and assert the sha256 equalsscripts/governance/package_agent.sh’ssource_hash()recomputation. Keep the exec-bit and__pycache__exclusion cases.verify_logs_test.sh: stubsterraform show -json(state) andgcloud logging read. Build the stubstate.jsonfrom aterraform show -jsonshape that contains OUR registry endpoint resources (names fromterraform/10-registry-endpoints.tf: read them). The four guards (empty registered set FATAL, truncated sample WARN, service_id collision WARN, empty window not clean) must each have a case.auth_provider_test.sh: OUR script targetsagentidentity.googleapis.com/v1AuthProviders with an API key (GTI), usesGETfor:getIamPolicy. Stubcurlto replay fixtures by URL substring; assert the script never prints the key value (grep stub log for the fake key stringFAKE-GTI-KEY-0001and assert absent from stdout/stderr).bind_ge_app_test.sh/ge_agent_test.sh: stubcurlandgcloud; cases: status unbound, bind when unbound (PATCH withupdateMask=agentGatewaySetting.defaultEgressAgentGateway.name), bind refuses when bound elsewhere withoutGE_FORCE_REBIND=1, unbind idempotent; forge_agent.sh: create adopts an existing registration pointing at the same reasoning engine instead of duplicating, delete only removes the matching one. These two harnesses are the safety net for S5.delete_until_gone_test.sh: stubgcloud; assert retry-until-404 and bounded attempts.sgp_test.sh: testssgp_gateway_config.sh; stubgcloud/curl; assert the generated gateway config JSON containsCONSTRAINTS_AND_INTENTfor the Tier-2 policy and the10stimeout.
Task 3.4: Python coverage from orchestrator_notice_test.py#
Read upstream
scripts/tests/orchestrator_notice_test.py. List its assertions. For each not covered bytests/test_governed_agents.py::test_soc_orchestrator_policy_block_banners(e.g. banner text for Model Armor block vs IAP 403 vs SGP deny, and that the orchestrator never retries a denied tool), add onedef test_...totests/test_governed_agents.pyusing the sameimportlib/MagicMockpattern the file already uses..venv/bin/python -m pytest -o addopts="" -p no:cacheprovider tests/test_governed_agents.py -q-> all pass, count > 6.git add tests/test_governed_agents.py && git commit -m "test(governance): cover orchestrator policy notices from reference harness"
Task 3.5: shellcheck clean + terraform fmt#
shellcheck -S warning scripts/governance/*.sh scripts/governance/tests/*.sh-> fix each finding minimally (SC2155: splitreadonly X="$(...)"into assignment thenreadonly X; SC1010: quote or restructuredone/fitokens). Re-run until no output;echo exit=$?->0.terraform -chdir=terraform fmt -recursive && terraform -chdir=terraform fmt -check -recursive; echo exit=$?->0.git diff --statshould touch only52-policies-access.tf(whitespace).Regression:
bash scripts/governance/tests/run_all.sh | tail -1->ALL GREEN;.venv/bin/python -m pytest -o addopts="" -p no:cacheprovider tests/test_governed_agents.py -q-> pass.git add scripts/governance/*.sh scripts/governance/tests/*.sh terraform/52-policies-access.tf && git commit -m "style(governance): make shell scripts shellcheck-clean and terraform fmt-clean"
Task 3.6: pre-commit hook, just recipes#
Append to
.pre-commit-config.yamlunderrepos:(before thelocalrepo):- repo: https://github.com/shellcheck-py/shellcheck-py rev: v0.10.0.1 hooks: - id: shellcheck name: shellcheck governance scripts files: ^scripts/governance/.*\.sh$ args: ['--severity=warning']
Append to
justfileaftergovernance-smoke-test:# Run every offline governance shell harness (no network, no credentials) governance-test: bash scripts/governance/tests/run_all.sh # Lint governance shell scripts and check Terraform formatting governance-lint: shellcheck --severity=warning scripts/governance/*.sh scripts/governance/tests/*.sh terraform -chdir=terraform fmt -check -recursive
just governance-test | tail -1->ALL GREEN;just governance-lint; echo exit=$?->0..venv/bin/python -m pre_commit run shellcheck --all-files->Passed.git add .pre-commit-config.yaml justfile && git commit -m "ci(governance): add shellcheck hook and governance-test/lint recipes"
Task 3.7: GitHub Actions workflow#
Create
.github/workflows/governance-ci.yml:name: Governance CI on: pull_request: types: [opened, synchronize, reopened] paths: - 'governed_agents/**' - 'scripts/governance/**' - 'terraform/**' - 'tests/test_governed_agents.py' - '.github/workflows/governance-ci.yml' push: branches: - main paths: - 'governed_agents/**' - 'scripts/governance/**' - 'terraform/**' - 'tests/test_governed_agents.py' permissions: contents: read jobs: shell-harnesses: name: Shell harnesses and shellcheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - name: Install shellcheck run: | sudo apt-get update sudo apt-get install -y shellcheck=0.9.0-1 - name: shellcheck run: shellcheck --severity=warning scripts/governance/*.sh scripts/governance/tests/*.sh - name: Offline harnesses run: bash scripts/governance/tests/run_all.sh python-tests: name: Governed agent unit tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: actions/setup-python@v6 with: python-version: '3.12' cache: 'pip' - name: Install pinned dependencies run: | pip install pytest==8.3.5 pip install -r governed_agents/soc_orchestrator/requirements.txt pip install -r governed_agents/cti_researcher/requirements.txt - name: pytest run: python -m pytest -o addopts="" tests/test_governed_agents.py terraform: name: Terraform fmt and validate runs-on: ubuntu-latest steps: - uses: actions/checkout@v5 - uses: hashicorp/setup-terraform@v3 with: terraform_version: 1.16.5 - name: fmt run: terraform -chdir=terraform fmt -check -recursive - name: Package agents and generate cards run: | bash scripts/governance/package_agent.sh all python3 scripts/governance/gen_agent_cards.py - name: validate run: | terraform -chdir=terraform init -backend=false -input=false terraform -chdir=terraform validate
If the Ubuntu runner’s apt shellcheck version pin
0.9.0-1is wrong forubuntu-latest, usepip install shellcheck-py==0.10.0.1instead and keep the pin.Local dry-run of the workflow steps that can run locally:
bash scripts/governance/package_agent.sh all && python3 scripts/governance/gen_agent_cards.py && terraform -chdir=terraform init -backend=false -input=false >/dev/null && terraform -chdir=terraform validate->Success!. Thengit status --short-> empty (cards deterministic).python3 -c "import yaml,sys; yaml.safe_load(open('.github/workflows/governance-ci.yml'))" && echo YAML_OK(use.venv/bin/pythonifyamlmissing).git add .github/workflows/governance-ci.yml && git commit -m "ci(governance): add Governance CI workflow for harnesses, unit tests, and terraform validate"
S3 GATE#
GATE S3-a:
just governance-test | tail -1->ALL GREEN: 7 harnesses, <m> checkswithm >= 40.GATE S3-b:
just governance-lint; echo exit=$?->0.GATE S3-c:
.venv/bin/python -m pytest -o addopts="" -p no:cacheprovider tests/test_governed_agents.py tests/test_check_public_repo_hygiene.py -q-> all pass (>= 12).GATE S3-d:
.venv/bin/ruff check governed_agents scripts/governance tests-> clean.GATE S3-e:
python3 scripts/check_public_repo_hygiene.py --git-range origin/main..HEAD; echo exit=$?->0.GATE S3-f:
.venv/bin/python -m pre_commit run --files $(git diff --name-only governance__terraform-and-a2a-agents..HEAD)-> all Passed/Skipped.GATE S3-g:
git status --shortempty;git log --oneline governance__terraform-and-a2a-agents..HEADshows 10 to 12 commits.Log S3 PASS with the harness/check counts.
S4: governance__docs (new, 2 h)#
Files:
Create:
docs/agent_governance.md(deploy, verify, operate; the public equivalent of the referenceREADME.mdDeploy/Verify sections plus the SecOps specifics)Create:
docs/agent_governance_design.md(public equivalent of referenceDESIGN.md: nine choke-point layers, identity model, three authorization layers, what is a shim, cost, credential handling)Create:
docs/agent_governance_troubleshooting.md(public equivalent of referenceSKILL.md: read the evidence first, the common 403/Model Armor/SGP/deployment_specfailure signatures and fixes)Create:
docs/superpowers/plans/2026-11-06-agent-governance-stack.md(sanitized copy of THIS handoff)Modify:
README.md(new## Agent Governancesection after## Gemini Enterprise Integration, plus a Table of Contents entry;docs/commands.mdgets thegovernance-*recipes)Modify:
CHANGELOG.md(oneUnreleasedentry per stack S1…S5)
Interfaces:
Consumes: exact
justrecipe names from S2/S3:governance-package,governance-cards,governance-init,governance-validate,governance-plan,governance-enforce,governance-logs,governance-smoke-test,governance-test,governance-lint,security-hygiene,security-hygiene-range.
Task 4.1: Worktree#
cd $WT/main && git worktree add ../governance__docs -b governance__docs governance__shell-tests-and-ci && cd ../governance__docs && ln -s ../governance__terraform-and-a2a-agents/.venv .venv. SetS4=$PWD.
Task 4.2: docs/agent_governance.md#
Read the reference
README.mdsectionsPrerequisites,Deploy(stages 0 to 7),Verify, andUpgrading a deployment made on google-beta 7.x. Read OURterraform/variables.tf,terraform/outputs.tf,terraform/terraform.tfvars.example,justfilegovernance block,scripts/governance/smoke_test.pyargparse, andscripts/governance/verify_logs.shusage header.Write the doc with these H2 sections, in this order:
What this adds(one paragraph + the nine layers as a table: layer, resource, Terraform file),Prerequisites(APIs, org policyiam.managed.disableAccessPolicyBinding, service identities foraiplatformanddiscoveryengine, an existing Gemini Enterprise app ID only if opting into publication, tools: terraform >= 1.9, jq, curl, shellcheck, just, uv),Configure(copyterraform/terraform.tfvars.example, every variable with its default and why),Deploy(the stagedterraform apply -targetsequence matching OUR file numbering 00…70, each stage with the exact command and expected output lines; include theGOOGLE_API_USE_CLIENT_CERTIFICATE=falsenote),Verify(just governance-smoke-testwith the 5 case IDs fromsmoke_test.pyand the exact expected verdict per case;just governance-logs action=denied,audit,who,mcp,unregistered; the “DRY_RUN = -” sentence),Operate(governance-enforcemodes, rotating the GTI key viaauth_provider.sh,delete_until_gone.sh),Publish to Gemini Enterprise(placeholder section to be completed in S5: thebind_ge_app/create_ge_agentopt-in and the rollback commands),Cost(table from memory topic, in USD with\$),Tests(just governance-test,just governance-lint, pytest command, what each harness proves).Every shell block defines variables before use. No internal hostnames, IDs, or go-links. Use
<PROJECT_ID>,<PROJECT_NUMBER>,<ORG_ID>,<GE_ENGINE_ID>.python3 scripts/check_public_repo_hygiene.py docs/agent_governance.md; echo exit=$?->0.git add docs/agent_governance.md && git commit -m "docs(governance): add deploy, verify, and operate guide for the governed SecOps stack"
Task 4.3: docs/agent_governance_design.md#
Read the reference
DESIGN.mdin full. Rewrite for SecOps (public wording):Architecturewith aflowchart LRmermaid diagram (Gemini Enterprise -> SOC Orchestrator -> 4 specialists -> Agent Gateway -> OneMCP / GTI),Every edge and the Terraform that creates it(table: edge, policy file, CEL attribute),Identity(SPIFFEprincipal://form with placeholders),Three layers, three different questions(IAP CEL allowlists, Model Armor, Semantic Governance; include the INTENT_ONLY vs CONSTRAINTS_AND_INTENT behavior and whylist_feedsis advertised on the threat hunter),Two rules the configuration is built around(defaults are the deployment; registry-wide IAM is never used),Which parts are shims(the fourterraform_data+ bash shims and when they go away),Hard limits(CEL 1024 chars, 10 list elements, 10 FGAC rules per policy, 4 custom policies per gateway),Credential handling(GTI API key lifecycle through Auth Manager; never injected by the gateway).python3 scripts/check_public_repo_hygiene.py docs/agent_governance_design.md; echo exit=$?->0.git add docs/agent_governance_design.md && git commit -m "docs(governance): add design notes for identity, authorization layers, and shims"
Task 4.4: docs/agent_governance_troubleshooting.md#
Read the reference
SKILL.mdin full. Write:Read the evidence before changing anything(the four log surfaces and the exactjust governance-logsinvocations), then one H3 per failure signature withSymptom/Evidence/Cause/Fix: 403 from IAP withGatekeeperAuthorizer.AuthorizeUser; 403 you cannot attribute (unregistered host);MODEL_ARMOR_SANITIZATION_VERDICT_BLOCKfalse positive; SGPDENYon an in-scope tool (INTENT_ONLY); Reasoning Engine 404 on Gemini 3.x model (MODEL_LOCATION);.rep.mtls.googleapis.comNXDOMAIN; perpetualdeployment_specdiff and why you must notignore_changes;FAILED_PRECONDITION networkservices.agentGateways.geton first apply (service identity);Maximum 10 FGAC conditions; SGP PSCstate = FAILEDwithACCEPTED; Gemini Enterprise bind refused because the app is bound elsewhere (GE_FORCE_REBIND=1).python3 scripts/check_public_repo_hygiene.py docs/agent_governance_troubleshooting.md; echo exit=$?->0.git add docs/agent_governance_troubleshooting.md && git commit -m "docs(governance): add troubleshooting guide keyed on log evidence"
Task 4.5: README, commands, CHANGELOG, sanitized plan#
README.md: add- [Agent Governance](#agent-governance)to the Table of Contents and a## Agent Governancesection (8 to 15 lines): what it is, one architecture sentence, the three-command quick path (just governance-init,just governance-validate,just governance-plan), and links to the three docs. Keep existing content untouched.docs/commands.md: add aGovernancesubsection listing eachgovernance-*andsecurity-hygiene*recipe with its one-line description copied from thejustfilecomments.CHANGELOG.md: under## [Unreleased](create if absent) add### Addedbullets: hygiene gate + CI (S1), governed A2A agents + Agent Gateway Terraform stack (S2), offline shell harnesses + Governance CI (S3), governance documentation (S4), Gemini Enterprise binding and publication of the governed orchestrator (S5, written now, verified in S5).Create
docs/superpowers/plans/2026-11-06-agent-governance-stack.mdby copying THIS file and then: delete theEnvironment Factssection, thePre-flightGE snapshot block, and every occurrence of project IDs, project numbers, engine IDs, account emails, GE app IDs, and absolute/usr/local/google/home/...paths (replace with<REPO_ROOT>); delete theMorning Reportsection; keep the stack layout, constraints, tasks, and gates. Thenpython3 scripts/check_public_repo_hygiene.py docs/superpowers/plans/2026-11-06-agent-governance-stack.md; echo exit=$?->0.git add README.md docs/commands.md CHANGELOG.md docs/superpowers/plans/2026-11-06-agent-governance-stack.md && git commit -m "docs(governance): link governance guides from README, commands, changelog, and plan"
S4 GATE#
GATE S4-a:
python3 scripts/check_public_repo_hygiene.py --git-range origin/main..HEAD; echo exit=$?->0, and--all-tracked->0.GATE S4-b:
.venv/bin/python -m pre_commit run --files $(git diff --name-only governance__shell-tests-and-ci..HEAD)-> Passed/Skipped (trailing whitespace, EOF, large files, gitleaks).GATE S4-c: every
justrecipe named in the three docs exists:for r in $(grep -oE 'just [a-z-]+' docs/agent_governance*.md | awk '{print $2}' | sort -u); do just --show "$r" >/dev/null 2>&1 || echo "MISSING $r"; done-> prints nothing. (This is a single-file grep over three small docs, allowed.)GATE S4-d: every
scripts/governance/*.shand*.pynamed in the docs exists:for f in $(grep -oE 'scripts/governance/[a-z_]+\.(sh|py)' docs/agent_governance*.md | sort -u); do [ -f "$f" ] || echo "MISSING $f"; done-> nothing.GATE S4-e: mermaid blocks render:
grep -c '```mermaid' docs/agent_governance_design.md->>= 1, and the block uses onlyflowchart LR/TD.GATE S4-f:
just governance-test | tail -1->ALL GREEN(docs stack must not regress S3);git status --shortempty;git log --oneline governance__shell-tests-and-ci..HEAD | wc -l->4.Log S4 PASS.
S5: governance__ge-binding (new, live, 1.5 h)#
Bind the shared Gemini Enterprise app <GE_ENGINE_ID> to the egress Agent Gateway and publish the governed soc_orchestrator into its agent picker, with rollback. The user has accepted the risk to the existing agent_soc_manager registration. Keep the binding in place even if the legacy agent degrades; report it prominently.
Files:
Modify:
terraform/terraform.tfvars.example(uncommented GE opt-in block with placeholder values and the rollback note)Modify:
justfile(addgovernance-ge-status,governance-ge-unbind,governance-ge-unpublish)Modify:
docs/agent_governance.md(complete thePublish to Gemini Enterprisesection with the verified procedure and rollback)Modify:
CHANGELOG.md(mark S5 entry verified)Local only (gitignored, never committed):
terraform/terraform.tfvars(bind_ge_app = true,create_ge_agent = true),terraform/terraform.tfstate*
Interfaces:
Consumes:
scripts/governance/bind_ge_app.sh {status|bind|unbind}andscripts/governance/ge_agent.sh {status|create|icon|delete}with envGE_PROJECT_ID GE_PROJECT_NUMBER GE_LOCATION GE_ENGINE_ID [GE_COLLECTION_ID] [GE_AGENT_GATEWAY] [GE_ASSISTANT_ID GE_REASONING_ENGINE ...]; Terraformterraform_data.ge_binding[0]andterraform_data.ge_agent[0]whose destroy provisioners rununbind/delete.
Task 5.1: Worktree and state hand-over#
cd $WT/main && git worktree add ../governance__ge-binding -b governance__ge-binding governance__docs && cd ../governance__ge-binding. SetS5=$PWD.ln -s ../governance__terraform-and-a2a-agents/.venv .venv && ln -s ../governance__terraform-and-a2a-agents/.gcloud .gcloud && cp $S2/.envrc .envrc && direnv allowMove live Terraform state (gitignored files) so there is exactly one copy:
cp $S2/terraform/terraform.tfvars $S5/terraform/terraform.tfvars mv $S2/terraform/terraform.tfstate $S5/terraform/terraform.tfstate mv $S2/terraform/terraform.tfstate.backup $S5/terraform/terraform.tfstate.backup mv $S2/terraform/terraform.tfstate.*.backup $S5/terraform/ 2>/dev/null || true ls $S2/terraform | grep -c tfstate # must print 0
Log:
S5 | state moved to governance__ge-binding/terraform | DONE.direnv exec . terraform -chdir=terraform init -input=false >/dev/null && direnv exec . terraform -chdir=terraform plan -input=false -detailed-exitcode -lock-timeout=60s >/tmp/s5-pre.txt 2>&1; echo exit=$?->0or2with NO destroy lines (grep -E "will be destroyed|must be replaced" /tmp/s5-pre.txtprints nothing). State is intact and the stack is still converged.git status --short-> empty (state files are ignored).
Task 5.2: Pre-bind snapshot and dry run#
Confirm pre-flight snapshots exist:
ls $EVID/S5/ge-app-before.json $EVID/S5/ge-agents-before.txt.Edit
terraform/terraform.tfvars(local, ignored): setbind_ge_app = true,create_ge_agent = true. Leavege_prompt_loggingat its default unlessvariables.tfdefaults it totrue; in that case setge_prompt_logging = falsetonight (do not enable sensitive prompt logging on a shared app without the user).direnv exec . terraform -chdir=terraform plan -input=false -lock-timeout=60s -out=/tmp/s5.tfplan 2>&1 | tee $EVID/S5/plan.txt | tail -15. Expected adds:terraform_data.ge_binding[0],terraform_data.ge_agent[0], and nothing destroyed/replaced amonggoogle_*resources. If anything other than those twoterraform_dataresources (and the knowndeployment_specin-place noise) changes: STOP, revert tfvars, write Morning Report.
Task 5.3: Apply, verify, record#
direnv exec . terraform -chdir=terraform apply -input=false -lock-timeout=60s /tmp/s5.tfplan 2>&1 | tee $EVID/S5/apply.txt | tail -20->Apply complete! Resources: 2 added, 0 changed, 0 destroyed.and provisioner linesbind_ge_app.sh: ok: all agent traffic for <GE_ENGINE_ID> now egresses through ...andge_agent.sh: ... created(oradopted).rm /tmp/s5.tfplan.GATE S5-a (binding):
GE_PROJECT_ID=<PROJECT_ID> GE_PROJECT_NUMBER=<PROJECT_NUMBER> GE_LOCATION=global GE_ENGINE_ID=<GE_ENGINE_ID> direnv exec . bash scripts/governance/bind_ge_app.sh status > $EVID/S5/ge-app-after.json-> stderris bound to projects/.../agentGateways/agw-secops-egress.GATE S5-b (publication):
direnv exec . just gem-ent-list-agents > $EVID/S5/ge-agents-after.txt 2>&1; the after list contains every agent name fromge-agents-before.txt(diff the sorted name columns: zero removed) plus exactly one new entry whose reasoning engine is.../reasoningEngines/<ORCHESTRATOR_ENGINE_ID>.GATE S5-c (gateway path still healthy):
direnv exec . just governance-smoke-test 2>&1 | tee $EVID/S5/smoke.txt | tail -8->5 passed, 0 failed.GATE S5-d (Gemini Enterprise -> gateway evidence): drive one request through the app so the gateway sees GE-originated traffic. Try the Discovery Engine REST path:
PROJECT_NUMBER=<PROJECT_NUMBER>; ENGINE_ID=<GE_ENGINE_ID> TOKEN=$(direnv exec . gcloud auth application-default print-access-token) AGENT_NAME=$(jq -r '.. | objects | select(has("adkAgentDefinition")) | .name' $EVID/S5/ge-agents-after.txt 2>/dev/null | head -1) curl -sS -X POST "https://discoveryengine.googleapis.com/v1alpha/projects/$PROJECT_NUMBER/locations/global/collections/default_collection/engines/$ENGINE_ID/assistants/default_assistant:streamAssist" \ -H "Authorization: Bearer $TOKEN" -H "X-Goog-User-Project: <PROJECT_ID>" -H "Content-Type: application/json" \ -d "{\"query\":{\"text\":\"List the detection rules currently enabled.\"},\"agentsConfig\":{\"agent\":\"$AGENT_NAME\"}}" \ | tee $EVID/S5/streamAssist.json | tail -c 1200
If
ge-agents-after.txtis not JSON, getAGENT_NAMEfromGE_... direnv exec . bash scripts/governance/ge_agent.sh status. If the request shape is rejected twice, record the two error bodies and mark S5-dSKIP (manual console check in the morning); this gate is informative, not blocking. Then:direnv exec . bash scripts/governance/verify_logs.sh audit --freshness 20m | tee $EVID/S5/audit.txt | tail -10-> rows forsoc_orchestratorafter the apply timestamp;verify_logs.sh who --freshness 20mlists the orchestrator and specialists only.GATE S5-e (legacy agent health, informative): with the same
streamAssistcall butAGENT_NAMEset to the pre-existingagent_soc_managerregistration fromge-agents-before.txt, record the HTTP status and first 600 bytes to$EVID/S5/legacy-agent.json. PASS if it answers; DEGRADED if it returns 403/permission text thatverify_logs.sh denied --freshness 10mattributes to the gateway (that is the expected effect of binding a shared app whose other agents are not registered). Either way, do NOT unbind; put the result in the first line of the Morning Report.
Task 5.4: Commit the reusable parts#
terraform/terraform.tfvars.example: add (with placeholders):# Gemini Enterprise opt-in (both default false; binding mutates a shared app) # ge_engine_id = "<GE_ENGINE_ID>" # ge_location = "global" # bind_ge_app = true # create_ge_agent = true # Rollback: set both back to false and run `terraform apply`; the destroy # provisioners run bind_ge_app.sh unbind and ge_agent.sh delete.
justfile, aftergovernance-smoke-test:# Show whether the Gemini Enterprise app is bound to the egress Agent Gateway governance-ge-status: bash scripts/governance/bind_ge_app.sh status bash scripts/governance/ge_agent.sh status # Emergency rollback: remove the governed orchestrator from the app, then unbind the gateway governance-ge-rollback: bash scripts/governance/ge_agent.sh delete bash scripts/governance/bind_ge_app.sh unbind
(These rely on
GE_*env vars; document thatterraform output -json ge_bindingprovides the values.)docs/agent_governance.md: completePublish to Gemini Enterprise: prerequisites (app exists, region pairingglobal->us-central1), the two tfvars, the apply output to expect, the three verification commands, the rollback (just governance-ge-rollbackor flipping the two vars and applying), and a WARNING that binding routes all of the app’s agent traffic through the gateway so pre-existing unregistered agents will be denied until registered.CHANGELOG.md: change the S5 bullet wording from planned to verified.python3 scripts/check_public_repo_hygiene.py --git-range origin/main..HEAD; echo exit=$?->0.git add terraform/terraform.tfvars.example justfile docs/agent_governance.md CHANGELOG.md && git commit -m "feat(governance): document and script Gemini Enterprise binding, publication, and rollback"
S5 GATE#
GATE S5-f:
git status --shortempty (state and tfvars ignored);git log --oneline governance__docs..HEAD | wc -l->1.GATE S5-g:
just governance-test | tail -1->ALL GREEN;just governance-lint; echo exit=$?->0(the new recipes did not break anything).GATE S5-h:
direnv exec . terraform -chdir=terraform plan -input=false -detailed-exitcode -lock-timeout=60s >/dev/null 2>&1; echo exit=$?->0(converged) or2with only the knowndeployment_specnoise.Log S5 PASS/DEGRADED.
Rollback Reference (do not run unless a GATE says STOP)#
GE only:
cd $S5 && direnv exec . terraform -chdir=terraform apply -input=false -var bind_ge_app=false -var create_ge_agent=false(destroy provisioners unbind and delete the registration), orjust governance-ge-rollbackwithGE_*exported fromterraform output -json ge_binding.Branches: nothing was pushed; a bad stack is just
git -C $WT/main worktree remove --force <path> && git -C $WT/main branch -D <branch>.State: if S5 was never applied, move
terraform.tfstate*back to$S2/terraform/and log it.