Skip to content

Commit 3514cf8

Browse files
Merge branch 'test/5655-port-network-l7-policy/matthewgrossman' into test/5676-port-docker-podman-features/matthewgrossman
Register the suites this branch adds as harnessless testkit programs (#5789) and move the OCSF record parser into a library so its unit tests still run. Signed-off-by: Matthew Grossman <mgrossman@nvidia.com>
2 parents 0fe5a8e + c40aaa0 commit 3514cf8

419 files changed

Lines changed: 11885 additions & 14667 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/agents/README.md‎

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Agents
2+
3+
Agents live in `.agents/agents/<name>/`. Names are descriptive nouns specifying the job, optionally qualified by adjectives: `labeler`, `reviewer`, or `security-reviewer`.
4+
5+
## Layout
6+
7+
```text
8+
.agents/
9+
|-- skills/
10+
| `-- agent-behavior -> ../agents/agent-name/skills/agent-behavior
11+
`-- agents/
12+
|-- README.md
13+
`-- agent-name/
14+
|-- README.md
15+
|-- run.py
16+
|-- bin/
17+
| |-- helper.py
18+
| `-- tool.py
19+
|-- prompts/
20+
| `-- task.md
21+
|-- skills/
22+
| `-- agent-behavior/
23+
| `-- SKILL.md
24+
|-- references/
25+
| `-- result-contract.md
26+
|-- tests/
27+
| |-- run_test.py
28+
| `-- tool_test.py
29+
|-- deploy/
30+
| |-- Dockerfile
31+
| `-- policy.yaml
32+
`-- evals/
33+
`-- cases.json
34+
```
35+
36+
Only `README.md` and a `run.*` entry point are required. Add other directories when needed; do not create empty scaffolding.
37+
38+
- `run.*` is the agent-root entry point for humans, workflows, and interactive callers. Use the implementation language's extension, such as `run.py` or `run.sh`. It can delegate to a shared launcher.
39+
- `bin/` holds supporting scripts, tools, and implementation modules.
40+
- `prompts/` holds model or harness prompts.
41+
- `skills/` holds canonical agent-owned skills. A symlink in [`.agents/skills/`](../skills) can expose the same skill for discovery. Reference canonical instructions and contracts rather than copying them.
42+
- `references/` holds contracts and supporting guidance.
43+
- `tests/` holds explicitly selected deterministic and integration tests.
44+
- `evals/` holds model-quality cases and scoring code.
45+
- `deploy/` holds execution-specific packaging assets, such as a Dockerfile and sandbox policy. Manifests and dependency files live at the agent root where their tooling expects them. Never commit secrets.
46+
- `README.md` covers setup, invocation, permissions, outputs, and recovery.
47+
48+
## Deterministic orchestration
49+
50+
The `labeler` agent checks authorization, acceptance, lifecycle, and material changes before calling a model-based classifier. The classifier receives prepared evidence and no tools; deterministic code validates and applies the result.
51+
52+
```text
53+
labeler/
54+
|-- README.md
55+
|-- run.py
56+
|-- bin/
57+
| |-- acceptance.py
58+
| |-- classifier.py
59+
| |-- evidence.py
60+
| `-- policy.py
61+
|-- prompts/
62+
| `-- classify.md
63+
|-- skills/
64+
| `-- label-issue/
65+
| |-- SKILL.md
66+
| `-- references/
67+
| `-- result-contract.md
68+
`-- tests/
69+
|-- run_test.py
70+
|-- acceptance_test.py
71+
|-- classifier_test.py
72+
|-- evidence_test.py
73+
`-- policy_test.py
74+
```
75+
76+
Execution: `run.py` -> deterministic gates -> prepared evidence -> model-based classifier -> validation and application. Deterministic skips create no model session. Acceptance recognizes established policy and human disposition; the model does not accept work.
77+
78+
## Harness-driven execution
79+
80+
A reviewer launches a model/harness with a prompt and selected tools. Its entry point enforces invocation scope and permissions; sandbox policy, guarded commands, or SDK tool handlers enforce tool access.
81+
82+
```text
83+
reviewer/
84+
|-- README.md
85+
|-- run.sh
86+
|-- agent.yaml
87+
|-- bin/
88+
| |-- read-item
89+
| `-- submit-findings
90+
|-- prompts/
91+
| `-- review.md
92+
|-- skills/
93+
| `-- review-item/
94+
| `-- SKILL.md
95+
|-- references/
96+
| `-- result-contract.md
97+
|-- deploy/
98+
| |-- Dockerfile
99+
| `-- policy.yaml
100+
`-- tests/
101+
|-- run_test.sh
102+
`-- submit_findings_test.sh
103+
```
104+
105+
Execution: `run.sh` -> scope checks -> harness with prompt and tools -> validated result. Tools can be registered SDK functions or guarded sandbox commands. Supervision and repeated cycles belong outside the model.
106+
107+
These examples illustrate execution styles, not an inventory of agents.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ COPY bin/gh /usr/local/bin/gh-gator
8787
COPY bin/review-feedback-ledger /usr/local/bin/review-feedback-ledger
8888
COPY bin/resolve-gator-review-threads /usr/local/bin/resolve-gator-review-threads
8989
COPY bin/validate-review-findings /usr/local/bin/validate-review-findings
90+
COPY bin/approve-gator-workflow /usr/local/bin/approve-gator-workflow
9091
RUN rm -f /usr/local/bin/gh && \
9192
cp /usr/local/bin/gh-gator /usr/local/bin/gh && \
9293
chmod 755 /usr/local/bin/gh /usr/local/bin/review-feedback-ledger \
9394
/usr/local/bin/resolve-gator-review-threads \
94-
/usr/local/bin/validate-review-findings
95+
/usr/local/bin/validate-review-findings /usr/local/bin/approve-gator-workflow
9596

9697
RUN printf 'export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin"\nexport PS1="\\u@\\h:\\w\\$ "\n' \
9798
> /sandbox/.bashrc && \
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
Launch a headless sandbox agent that runs the `gator-gate` skill against OpenShell issues and pull requests. The default and currently only supported harness is Codex.
44

5+
The agent-root entry point is `.agents/agents/gator/run.sh`.
6+
57
## Prerequisites
68

7-
- `gh` is authenticated on the host and has access to `NVIDIA/OpenShell`.
9+
- `gh` is authenticated on the host and has access to `ai-openshell/openshell`.
810
- For `--harness codex`, `codex login` has created `$HOME/.codex/auth.json`.
911
- For `--harness codex`, local Codex auth must include an access token, refresh token, and account ID.
1012
- A Docker, Podman, or Kubernetes gateway is available. Local builds require
@@ -13,14 +15,13 @@ Launch a headless sandbox agent that runs the `gator-gate` skill against OpenShe
1315
## Usage
1416

1517
```shell
16-
./scripts/agents/run.sh \
17-
--agent gator \
18+
./.agents/agents/gator/run.sh \
1819
--gateway docker-dev \
1920
--harness codex \
2021
"Run gator on PR 1536 and keep watching until it closes or merges."
2122
```
2223

23-
By default the launcher uses `scripts/agents/gator/Dockerfile` as the sandbox image source. It builds `scripts/agents/gator/` as the image context, so gator-specific image files such as `policy.yaml` and `bin/gh` stay with the gator agent. The launcher bakes a task-independent prompt template, skills, subagents, and shared runtime files into `/etc/openshell/agent-payload`, then passes the resulting image reference to `openshell sandbox create`.
24+
By default the launcher uses `.agents/agents/gator/Dockerfile` as the sandbox image source. It builds `.agents/agents/gator/` as the image context, so gator-specific image files such as `policy.yaml` and `bin/gh` stay with the gator agent. The launcher bakes a task-independent prompt template, skills, subagents, and shared runtime files into `/etc/openshell/agent-payload`, then passes the resulting image reference to `openshell sandbox create`.
2425

2526
The PR assignment, operator test authorization, harness selection, watch mode, and polling interval are runtime inputs, not rendered image contents. The launcher supplies the non-secret assignment as `OPENSHELL_AGENT_TASK` in the canonical process command. The supervisor assembles the prompt once in memory and sends it to each harness cycle on stdin; cycles do not read task instructions from an agent-writable file. Assignment text is literal data, so shell syntax and template tokens inside it are not evaluated. Do not put credentials in assignments; use providers. Runtime command metadata can contain the assignment. This separates reusable tooling from per-run instructions; it does not make prompt instructions a security boundary.
2627

@@ -41,8 +42,8 @@ requires the matching current kube context and a running local cluster, builds
4142
with Docker, and imports the image into that cluster before creating a sandbox:
4243

4344
```shell
44-
OPENSHELL_WORKSPACE=gator mise exec k3d@5.9.0 -- ./scripts/agents/run.sh \
45-
--agent gator --gateway openshell-dev-main \
45+
OPENSHELL_WORKSPACE=gator mise exec k3d@5.9.0 -- ./.agents/agents/gator/run.sh \
46+
--gateway openshell-dev-main \
4647
--k3d-cluster openshell-dev-main --name gtr-pr-1234 --watch \
4748
"Review and monitor PR #1234 through the gator-gate workflow."
4849
```
@@ -57,8 +58,8 @@ changing gateway settings, importing providers, reading provider credentials,
5758
or launching a sandbox:
5859

5960
```shell
60-
./scripts/agents/run.sh --agent gator --gateway remote-kube \
61-
--publish-image registry.example.com/team/gator:payload-13 --build-only
61+
./.agents/agents/gator/run.sh --gateway remote-kube \
62+
--publish-image registry.example.com/team/gator:payload-14 --build-only
6263
```
6364

6465
The builder uses existing Docker/Podman registry authentication. Both local and
@@ -71,8 +72,8 @@ The launcher prints `Tooling image: REGISTRY/REPOSITORY@sha256:DIGEST` after a
7172
successful push. Reuse that full reference for subsequent tasks:
7273

7374
```shell
74-
OPENSHELL_WORKSPACE=gator ./scripts/agents/run.sh \
75-
--agent gator --gateway remote-kube --name gtr-pr-1234 --watch \
75+
OPENSHELL_WORKSPACE=gator ./.agents/agents/gator/run.sh \
76+
--gateway remote-kube --name gtr-pr-1234 --watch \
7677
--image "$GATOR_IMAGE" \
7778
"Review and monitor PR #1234 through the gator-gate workflow."
7879
```
@@ -107,7 +108,7 @@ The launcher:
107108
- Selects the requested harness and bakes the common runtime into the immutable sandbox payload.
108109
- Builds with the latest Codex CLI by default. Docker can reuse the cached install layer; rebuild with that layer's cache disabled to fetch a newer release.
109110
- For `--harness codex`, imports `providers/codex-gator.yaml`, creates or updates the `codex-gator` provider from `$HOME/.codex/auth.json`, and stores the refresh token as gateway-only refresh material.
110-
- For `--harness codex`, configures gateway-managed refresh for `CODEX_AUTH_ACCESS_TOKEN` and rotates it before launching the sandbox.
111+
- For `--harness codex`, reuses gateway-managed refresh for `CODEX_AUTH_ACCESS_TOKEN`. Initial setup and explicit resets configure and rotate it once.
111112
- Passes the non-secret Codex account ID from host auth as `CODEX_ACCOUNT_ID`. The harness writes it literally into `auth.json` for local workspace discovery; access tokens remain opaque provider placeholders and refresh tokens remain gateway-only.
112113
- Enables `agent_policy_proposals_enabled` and `proposal_approval_mode=auto` on the gator sandbox only. Gateway-global values for these keys take precedence; the launcher does not change them.
113114
- Uses the gator image policy copied to `/etc/openshell/policy.yaml`.
@@ -122,8 +123,8 @@ The launcher:
122123
Gator-owned GitHub review thread without touching human review threads.
123124
- Installs `gator/bin/validate-review-findings` to downgrade blockers that lack the required reachability, ownership, base-vs-head, impact, and reproducer evidence.
124125
- Keeps that normalized evidence as Gator's internal review contract, then renders validated blockers for people as a read-aloud `Summary`, an actionable `Fix`, and a deterministic `Verify`. Exact paths and only the additional provenance an implementation agent needs appear in collapsed `Agent context`; raw evidence headings such as `Base` and `Head` are not posted publicly. Review-process provenance, docs and E2E disposition, SHAs, and state codes appear at the end of the summary in collapsed `Gator metadata`, while required human actions remain visible.
125-
- Bakes `scripts/agents/gator/skills/gator-gate/SKILL.md` into `/etc/openshell/agent-payload`.
126-
- Bakes `.claude/agents/principal-engineer-reviewer.md` so the selected harness can run a deterministic independent reviewer execution through `/etc/openshell/agent-payload/runtime/subagent.sh principal-engineer-reviewer < task.md`.
126+
- Bakes `.agents/agents/gator/skills/gator-gate/SKILL.md` into `/etc/openshell/agent-payload`.
127+
- Bakes `.agents/agents/principal-engineer-reviewer/prompts/principal-engineer-reviewer.md` so the selected harness can run a deterministic independent reviewer execution through `/etc/openshell/agent-payload/runtime/subagent.sh principal-engineer-reviewer < task.md`.
127128
- For `--harness codex`, optionally bakes a host Codex executable as `/etc/openshell/agent-payload/runtime/harnesses/codex/codex`.
128129
- Starts the selected harness without a TTY.
129130
- Runs gator in `watch` mode by default. The sandbox stays alive while the supervisor sleeps between bounded Codex cycles, so Codex is not connected during passive PR waits. The supervisor prints periodic heartbeat lines during active cycles and passive sleeps.
@@ -134,17 +135,20 @@ Set `GATOR_CODEX_ACCESS_CREDENTIAL_KEY` or pass `--codex-access-key` if the gato
134135

135136
Use `--once` for a single reconciliation cycle. Use `--poll-interval <seconds>` to change the default 15-minute watch cadence.
136137

137-
The launcher preserves existing gateway-owned Codex refresh material by default so multiple gator sandboxes do not overwrite each other's refresh-token lineage from host Codex auth. If gateway rotation fails, the launcher automatically resets gateway refresh material from host Codex auth and retries once. After `codex logout && codex login`, you can also pass `--reset-refresh` to force that reset before rotation.
138+
The launcher preserves gateway-owned Codex refresh material without reading host refresh material or forcing rotation on subsequent launches. Lookup, configuration, and rotation errors fail the launch rather than triggering an automatic reset. After reauthenticating Codex locally, pass `--reset-refresh` only when you intend to replace the shared provider's refresh ownership; this affects other sandboxes using that provider.
139+
140+
Workspace secrets are optional. Existing provider-owned refresh material remains supported; do not move a rotating Codex refresh token into a shared workspace secret merely to launch more Gators.
141+
142+
## GitHub workflow approval
143+
144+
Test labels select CI suites. Gator can approve current-head workflow runs only
145+
with explicit launch authorization. PRs changing `.github/` require manual
146+
approval. PR approval, merging, reruns, and dispatch require separate authorization.
138147

139148
## Tests
140149

150+
The test suite requires Bash, Ruby, Node.js, jq, and ripgrep on the host. It mocks image, gateway, credential, and GitHub operations.
151+
141152
```shell
142-
bash scripts/agents/gator/bin/gh_guard_test.sh
143-
bash scripts/agents/gator/bin/review_feedback_ledger_test.sh
144-
bash scripts/agents/gator/bin/resolve_gator_review_threads_test.sh
145-
bash scripts/agents/runtime/harnesses/codex/exec_test.sh
146-
bash scripts/agents/run_test.sh
147-
bash scripts/agents/image_test.sh
148-
bash scripts/agents/runtime/launch_test.sh
149-
bash scripts/agents/runtime/supervisor_test.sh
153+
mise run test:gator
150154
```
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
id: gator
5-
payload_version: 13
5+
payload_version: 15
66
display_name: Gator Gate Agent
77
description: Validate and monitor OpenShell GitHub issues and pull requests through the gator state machine.
88

@@ -87,7 +87,7 @@ resources:
8787

8888
subagents:
8989
- id: principal-engineer-reviewer
90-
source: repo://.claude/agents/principal-engineer-reviewer.md
90+
source: repo://.agents/agents/principal-engineer-reviewer/prompts/principal-engineer-reviewer.md
9191
destination: subagents/principal-engineer-reviewer.md
9292
expose_as: REVIEWER_COMMAND
9393

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
set -euo pipefail
5+
6+
# The authorization flag records the operator decision; it is not an auth boundary.
7+
if [[ $# != 3 || "$1" != --operator-authorized || ! "$2" =~ ^[0-9]+$ || ! "$3" =~ ^[0-9]+$ ]]; then
8+
echo 'Usage: approve-gator-workflow --operator-authorized PR_NUMBER RUN_ID' >&2
9+
exit 2
10+
fi
11+
repo=ai-openshell/openshell
12+
pr="$2" run="$3"
13+
deny() { echo "Workflow not approved: $*" >&2; exit 1; }
14+
actor="$(gh api user --jq .login)"
15+
permission="$(gh api "repos/$repo/collaborators/$actor/permission" --jq .permission)"
16+
case "$permission" in admin|maintain|write) ;; *) deny 'repository write permission is required' ;; esac
17+
pull="$(gh api "repos/$repo/pulls/$pr")"
18+
head="$(jq -er '.head.sha' <<< "$pull")"
19+
jq -e --arg repo "$repo" '.state == "open" and .draft == false and (.base.repo.full_name | ascii_downcase) == ($repo | ascii_downcase)' <<< "$pull" >/dev/null || deny 'PR is not open and ready in the target repository'
20+
21+
check_run() {
22+
local metadata
23+
metadata="$(gh api "repos/$repo/actions/runs/$run")"
24+
jq -e --arg repo "$repo" --arg head "$head" --argjson pr "$pr" '
25+
(.repository.full_name | ascii_downcase) == ($repo | ascii_downcase) and .event == "pull_request" and
26+
.head_sha == $head and .conclusion == "action_required" and
27+
any(.pull_requests[]; .number == $pr) and
28+
(.path == ".github/workflows/branch-checks.yml" or
29+
.path == ".github/workflows/branch-e2e.yml" or
30+
.path == ".github/workflows/helm-lint.yml" or
31+
.path == ".github/workflows/trivy-changes.yml" or
32+
.path == ".github/workflows/dependency-review.yml" or
33+
.path == ".github/workflows/workflow-security.yml" or
34+
.path == ".github/workflows/windows-msvc.yml")
35+
' <<< "$metadata" >/dev/null || deny 'run is not a recognized pending PR-head workflow'
36+
}
37+
check_run
38+
# A workflow approval executes PR-controlled workflow code. Require a human to
39+
# approve runs that change CI machinery, rather than trying to judge it here.
40+
pages="$(gh api --paginate "repos/$repo/pulls/$pr/files?per_page=100")"
41+
count="$(jq -se 'add | length' <<< "$pages")"
42+
expected="$(jq -er '.changed_files' <<< "$pull")"
43+
[[ "$count" == "$expected" ]] || deny 'changed-file listing is incomplete'
44+
files="$(jq -sr 'add | .[] | .filename, (.previous_filename // empty)' <<< "$pages")"
45+
if grep -Eq '^\.github/' <<< "$files"; then
46+
deny 'PR changes .github/; a maintainer must inspect and approve the run manually'
47+
fi
48+
current="$(gh api "repos/$repo/pulls/$pr" --jq .head.sha)"
49+
[[ "$current" == "$head" ]] || deny 'PR head changed during approval checks'
50+
check_run
51+
gh api --method POST "repos/$repo/actions/runs/$run/approve"
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)