Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .agents/skills/launch-openshell-gator/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ For gator's PR/issue validation policy, load `gator-gate` inside the launched sa
| `scripts/agents/gator/Dockerfile` | Gator sandbox image source. Local launches build this image through OpenShell. |
| `scripts/agents/gator/policy.yaml` | Sandbox policy for the gator agent. |
| `scripts/agents/gator/bin/gh` | Gator-specific `gh` wrapper and same-SHA duplicate-post guard. |
| `scripts/agents/gator/bin/review-feedback-ledger` | Builds tree-aware review scope, durable findings, convergence telemetry, and checkpoint state. |
| `scripts/agents/gator/bin/review-feedback-ledger` | Builds tree-aware review scope, durable findings, convergence telemetry, and review-budget state. |
| `scripts/agents/gator/bin/validate-review-findings` | Enforces the blocker evidence schema and downgrades unsupported hypotheses. |
| `scripts/agents/gator/prompts/gator.md` | Rendered top-level prompt template baked into the payload. |
| `scripts/agents/gator/skills/gator-gate/SKILL.md` | In-sandbox gator state-machine skill. |
Expand Down Expand Up @@ -217,7 +217,7 @@ sandbox_name="gator-pr-${pr_number}-supervised"
--name "$sandbox_name" \
--watch \
--background \
"Review and monitor PR #${pr_number} through the gator-gate workflow. Scope this invocation only to PR #${pr_number}. The operator explicitly authorizes applying the test:e2e label and posting /ok to test for the current head SHA if gator determines that is required."
"Review and monitor PR #${pr_number} through the gator-gate workflow. Scope this invocation only to PR #${pr_number}. The operator explicitly authorizes applying the test:e2e label, posting /ok to test for the current head SHA, and rerunning the relevant current-head workflow when the E2E Label Help bot says that is required."
```

## Model Or Image Experiments
Expand Down
6 changes: 2 additions & 4 deletions crates/openshell-supervisor-network/src/l7/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2155,7 +2155,7 @@ fn evaluate_l7_request_once(
));
}

let input_json = serde_json::json!({
let input = serde_json::json!({
"network": {
"host": ctx.host,
"port": ctx.port,
Expand All @@ -2179,9 +2179,7 @@ fn evaluate_l7_request_once(
.lock()
.map_err(|_| miette!("OPA engine lock poisoned"))?;

engine
.set_input_json(&input_json.to_string())
.map_err(|e| miette!("{e}"))?;
crate::opa::set_regorus_input(&mut engine, input)?;

let allowed = engine
.eval_rule("data.openshell.sandbox.allow_request".into())
Expand Down
72 changes: 39 additions & 33 deletions crates/openshell-supervisor-network/src/opa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,9 +461,7 @@ impl OpaEngine {
});
}

engine
.set_input_json(&input_json.to_string())
.map_err(|e| miette::miette!("{e}"))?;
set_regorus_input(&mut engine, input_json)?;

let allowed = engine
.eval_rule("data.openshell.sandbox.allow_network".into())
Expand Down Expand Up @@ -524,9 +522,7 @@ impl OpaEngine {
return Ok((NetworkAction::Deny { reason }, generation));
}

engine
.set_input_json(&input_json.to_string())
.map_err(|e| miette::miette!("{e}"))?;
set_regorus_input(&mut engine, input_json)?;

let action_val = engine
.eval_rule("data.openshell.sandbox.network_action".into())
Expand Down Expand Up @@ -823,9 +819,7 @@ impl OpaEngine {
.map_err(|_| miette::miette!("OPA engine lock poisoned"))?;
let generation = self.current_generation();

engine
.set_input_json(&input_json.to_string())
.map_err(|e| miette::miette!("{e}"))?;
set_regorus_input(&mut engine, input_json)?;

let val = engine
.eval_rule("data.openshell.sandbox._matching_endpoint_configs".into())
Expand Down Expand Up @@ -883,9 +877,7 @@ impl OpaEngine {
.lock()
.map_err(|_| miette::miette!("OPA engine lock poisoned"))?;

engine
.set_input_json(&input_json.to_string())
.map_err(|e| miette::miette!("{e}"))?;
set_regorus_input(&mut engine, input_json)?;

let val = engine
.eval_rule("data.openshell.sandbox.exact_declared_endpoint_host".into())
Expand Down Expand Up @@ -1000,6 +992,20 @@ fn network_input_json(input: &NetworkInput) -> serde_json::Value {
})
}

/// Sets an already-built JSON value as Regorus input without encoding and reparsing JSON text.
///
/// The explicit fallible conversion preserves evaluator errors because Regorus's infallible
/// `From<serde_json::Value>` conversion maps failures to [`regorus::Value::Undefined`].
pub(crate) fn set_regorus_input(
engine: &mut regorus::Engine,
input: serde_json::Value,
) -> Result<()> {
let input =
serde_json::from_value::<regorus::Value>(input).map_err(|e| miette::miette!("{e}"))?;
engine.set_input(input);
Ok(())
}

fn query_middleware_chain_locked(
engine: &mut regorus::Engine,
input: &NetworkInput,
Expand Down Expand Up @@ -2788,7 +2794,7 @@ process:

fn eval_l7(engine: &OpaEngine, input: &serde_json::Value) -> bool {
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input.clone()).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -2803,7 +2809,7 @@ process:
engine
.add_data_json(&data.to_string())
.expect("add raw data json");
engine.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut engine, input).unwrap();
let val = engine
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand Down Expand Up @@ -3080,7 +3086,7 @@ process:
}]),
);
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.request_deny_reason".into())
.unwrap();
Expand Down Expand Up @@ -4383,7 +4389,7 @@ network_policies:
let engine = l7_engine();
let input = l7_input("api.example.com", 8080, "DELETE", "/repos/myorg/foo");
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.request_deny_reason".into())
.unwrap();
Expand Down Expand Up @@ -4777,7 +4783,7 @@ network_policies:
// Verify the cloned engine can evaluate
let input_json = l7_input("api.example.com", 8080, "GET", "/repos/myorg/foo");
let mut eng = cloned.engine().lock().unwrap();
eng.set_input_json(&input_json.to_string()).unwrap();
set_regorus_input(&mut eng, input_json).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand Down Expand Up @@ -4819,7 +4825,7 @@ network_policies:
.clone_engine_for_tunnel(engine.current_generation())
.unwrap();
let mut eng = cloned.engine().lock().unwrap();
eng.set_input_json(&input_json.to_string()).unwrap();
set_regorus_input(&mut eng, input_json).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand Down Expand Up @@ -5019,7 +5025,7 @@ process:
"/repos/myorg/pulls/123/reviews",
);
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5036,7 +5042,7 @@ process:
// GET repos/issues is allowed and not denied
let input = l7_input("api.github.com", 443, "GET", "/repos/myorg/issues");
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5053,7 +5059,7 @@ process:
// POST to issues is allowed (deny only targets reviews)
let input = l7_input("api.github.com", 443, "POST", "/repos/myorg/issues");
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5070,7 +5076,7 @@ process:
// GET /repos/myorg/rulesets should be denied (method: "*")
let input = l7_input("api.github.com", 443, "GET", "/repos/myorg/rulesets");
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5091,7 +5097,7 @@ process:
"/repos/myorg/branches/main/protection",
);
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5112,7 +5118,7 @@ process:
"/repos/myorg/pulls/123/reviews",
);
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.request_deny_reason".into())
.unwrap();
Expand All @@ -5138,7 +5144,7 @@ process:
serde_json::json!({"force": ["true"]}),
);
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5161,7 +5167,7 @@ process:
serde_json::json!({"force": ["false"]}),
);
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5186,7 +5192,7 @@ process:
serde_json::json!({"force": ["true", "false"]}),
);
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand All @@ -5204,7 +5210,7 @@ process:
// so no match (key not present) and request should be allowed
let input = l7_input("api.restricted.com", 443, "POST", "/admin/settings");
let mut eng = engine.engine.lock().unwrap();
eng.set_input_json(&input.to_string()).unwrap();
set_regorus_input(&mut eng, input).unwrap();
let val = eng
.eval_rule("data.openshell.sandbox.allow_request".into())
.unwrap();
Expand Down Expand Up @@ -7721,11 +7727,11 @@ host_match if {
];
for (pattern, host) in cases {
let rust = openshell_core::host_pattern::host_matches(pattern, host).unwrap();
engine
.set_input_json(
&serde_json::json!({ "pattern": pattern, "host": host }).to_string(),
)
.unwrap();
set_regorus_input(
&mut engine,
serde_json::json!({ "pattern": pattern, "host": host }),
)
.unwrap();
let rego = engine.eval_rule("data.test.host_match".into()).unwrap()
== regorus::Value::from(true);
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion scripts/agents/gator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The launcher:
- Enables `providers_v2_enabled`, `agent_policy_proposals_enabled`, and `proposal_approval_mode=auto` at gateway scope.
- Uses the gator image policy copied to `/etc/openshell/policy.yaml`.
- Installs the gator-specific `gh` wrapper from `gator/bin/gh` as `/usr/local/bin/gh` to fail closed when same-head-SHA history cannot be checked, prevent duplicate dispositions, and require versioned review payloads.
- Installs `gator/bin/review-feedback-ledger` as `/usr/local/bin/review-feedback-ledger` so reviews receive tree- and patch-aware scope, prior summaries and findings, resolution state, convergence telemetry, and the three-round human checkpoint.
- Installs `gator/bin/review-feedback-ledger` as `/usr/local/bin/review-feedback-ledger` so reviews receive tree- and patch-aware scope, prior summaries and findings, resolution state, convergence telemetry, and the three-round Warning budget.
- Installs `gator/bin/validate-review-findings` to downgrade blockers that lack the required reachability, ownership, base-vs-head, impact, and reproducer evidence.
- Bakes `scripts/agents/gator/skills/gator-gate/SKILL.md` into `/etc/openshell/agent-payload`.
- 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`.
Expand Down
2 changes: 1 addition & 1 deletion scripts/agents/gator/agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

id: gator
payload_version: 3
payload_version: 4
display_name: Gator Gate Agent
description: Validate and monitor OpenShell GitHub issues and pull requests through the gator state machine.

Expand Down
2 changes: 1 addition & 1 deletion scripts/agents/gator/bin/gh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set -euo pipefail

REAL_GH="${OPENSHELL_REAL_GH:-/usr/bin/gh}"
GATOR_MARKER='> **gator-agent**'
GATOR_PAYLOAD_VERSION="${OPENSHELL_AGENT_PAYLOAD_VERSION:-3}"
GATOR_PAYLOAD_VERSION="${OPENSHELL_AGENT_PAYLOAD_VERSION:-4}"

if [[ $# -lt 1 || "$1" != "api" ]]; then
exec "$REAL_GH" "$@"
Expand Down
10 changes: 5 additions & 5 deletions scripts/agents/gator/bin/gh_guard_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ run_review_case() {
## PR Review Status

Head SHA: `0e4d7af7722fbedce2307d571b0c937a1eb3250f`' \
--arg payload 'Gator payload: `3`' \
--arg payload 'Gator payload: `4`' \
--arg inline_body '> **gator-agent**

**Warning:** Keep this validation bound to the accepted value.' \
Expand Down Expand Up @@ -142,7 +142,7 @@ same_sha_body='> **gator-agent**
## PR Review Status

Head SHA: `0e4d7af7722fbedce2307d571b0c937a1eb3250f`
Gator payload: `3`'
Gator payload: `4`'

run_case "blocks duplicate marked comment" \
"$same_sha_body" \
Expand All @@ -169,7 +169,7 @@ run_case "allows first versioned review disposition" \
## PR Review Status

Head SHA: `0e4d7af7722fbedce2307d571b0c937a1eb3250f`
Gator payload: `3`' \
Gator payload: `4`' \
0

run_case "allows unmarked comment" \
Expand Down Expand Up @@ -224,7 +224,7 @@ Gator is blocked from completing the required independent re-review for current
## PR Review Status

Head SHA: `0e4d7af7722fbedce2307d571b0c937a1eb3250f`
Gator payload: `3`' \
Gator payload: `4`' \
0

draft_blocked_body='> **gator-agent**
Expand All @@ -244,7 +244,7 @@ run_case "ignores draft blocker after PR is ready" \
## PR Review Status

Head SHA: `0e4d7af7722fbedce2307d571b0c937a1eb3250f`
Gator payload: `3`' \
Gator payload: `4`' \
0 \
false

Expand Down
12 changes: 6 additions & 6 deletions scripts/agents/gator/bin/review-feedback-ledger
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ read_input "$@" | jq '
}
end
| {
schema_version: 3,
schema_version: 4,
pr_author: ([.thread_pages[] | thread_pull_request.author.login][0] // null),
current_head_sha: (
[.thread_pages[] | thread_pull_request.headRefOid]
Expand Down Expand Up @@ -412,7 +412,7 @@ read_input "$@" | jq '
else null
end
),
convergence_checkpoint_required: (.finding_bearing_rounds >= 3),
review_budget_exhausted: (.finding_bearing_rounds >= 3),
current_patch_matches_last_review: (
.current_patch_id != null and
.last_reviewed_patch_id != null and
Expand All @@ -428,8 +428,8 @@ read_input "$@" | jq '
.review_telemetry.current_patch_matches_last_review
) then
"already_reviewed"
elif .review_telemetry.convergence_checkpoint_required then
"human_checkpoint"
elif .review_telemetry.review_budget_exhausted then
"critical_only"
else
"follow_up"
end
Expand All @@ -441,8 +441,8 @@ read_input "$@" | jq '
current_merge_base_sha: .current_merge_base_sha,
current_patch_id: .current_patch_id,
rebase_equivalent: .review_telemetry.current_patch_matches_last_review,
convergence_checkpoint_required:
.review_telemetry.convergence_checkpoint_required
review_budget_exhausted:
.review_telemetry.review_budget_exhausted
}
| if .pr_author == null then
error("pull request not found in ledger input")
Expand Down
Loading
Loading