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
7 changes: 4 additions & 3 deletions hack/automation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Workflows run them with a token of the `ai-openshell-sdk-go` GitHub App (`ai-ope
| `rpc-marker.jq` | | The hidden issue marker, parsed by `rpc-issues.jq` and `update-drift-issue.sh` (jq module). |
| `rpc-issue-body.md` | | Issue body template for `rpc-issues.jq`. |
| `rpc-coverage.sh` | | The coverage rule shared by `rpc-issues.sh` and `drift-check.sh` (sourced, not run). |
| `rpc-issues-lib.sh` | | Exceptions list parser (sourced, not run). |
| `rpc-issues-lib.sh` | | Exceptions list parser and helpers for listing the bot's issues (sourced, not run). |
| `rpc-exceptions.txt` | | RPCs the SDK deliberately does not wrap, one `Service.Method reason` per line. |
| `rpc-issues-test.sh [--update]` | | Offline planner, `rpc-issues.sh --plan-input`, coverage, exceptions, and drift link tests on `testdata/rpc-issues/`; part of `workflows:check`. |
| `report-failure.sh <job> <run-url>` | | Append a dated failure line to the drift issue. Called from `if: failure()` steps. |
| `report-failure.sh <job> <run-url>` | | Record a failed run in the drift issue: one dated line per job and day, with the latest run and a count when the job fails again that day. Called from `if: failure()` steps. |
| `drift-issue.sh` | | Shared helpers for the two drift issue scripts (sourced, not run). |
| `start-gateway.sh <core-semver>`, `stop-gateway.sh` | | Run the published gateway container for a core version with the Docker driver and a plaintext endpoint for the E2E lane, and collect its log. |

Expand All @@ -42,7 +42,8 @@ Workflows run them with a token of the `ai-openshell-sdk-go` GitHub App (`ai-ope
- **Coverage**: an RPC is covered when a package under `openshell/v1` (tests and `fake/` excluded) that calls `New<Service>Client(` also calls `.<Method>(` (`rpc-coverage.sh`, also used by `drift-check.sh`).
- **Grouping**: when the SDK wraps none of a service's user-facing methods, one issue tracks the whole service; otherwise each method gets its own issue.
The hidden marker on the first body line (`<!-- rpc-coverage: kind=... -->`) is the issue's identity; an issue keeps the methods its marker lists, and new methods of a service join its open service issue.
Only issues the bot opened and that keep the `rpc-coverage` label count; a marker in any other issue is ignored.
Only issues the bot opened count, found by creator and marker rather than by label: a marker in any other issue is ignored, and an issue whose `rpc-coverage` label someone removed gets the label back instead of a duplicate.
Text from core's proto comments is defused before it goes into a body (`@name`, `#123`, and `<!--` get a zero-width space), so it cannot mention people, link issues of this repository, or hide the rest of the body.
- **Lifecycle**: each run opens missing issues, rewrites a body or the `rpc:ready` / `rpc:blocked` label when they change, closes an issue with a reason per method (`covered`, `removed`, `excepted`, `not-user-facing`, or `tracked-elsewhere` when another issue's marker lists the method), and reopens an issue it closed itself when the methods apply again.
An issue a maintainer closes stays closed (a closed service issue silences the whole service); an issue a maintainer reopens is never closed as `covered` again.
- **Excluding an RPC**: add `Service.Method reason` to `rpc-exceptions.txt`; the next run closes its issue with the reason.
Expand Down
19 changes: 19 additions & 0 deletions hack/automation/drift-issue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ failure_lines() {
f && /^- / { print }' <<<"$1"
}

# add_failure_line <failure-lines> <date> <job> <run-url>: the failure lines
# with one more failed run recorded. A job that already has a line for the
# date keeps that one line, now naming the latest run and the number of
# failed runs ("- <date> <job> <url> (<n> runs)"), so an hourly job that keeps
# failing adds one line per day instead of one per run.
add_failure_line() {
awk -v d="${2:?add_failure_line needs a date}" -v j="${3:?add_failure_line needs a job}" \
-v u="${4:?add_failure_line needs a run URL}" '
NF == 0 { next }
!seen && $1 == "-" && $2 == d && $3 == j {
seen = 1; n = 1
if ($5 ~ /^\([0-9]+$/) n = substr($5, 2) + 0
printf "- %s %s %s (%d runs)\n", d, j, u, n + 1
next
}
{ print }
END { if (!seen) printf "- %s %s %s\n", d, j, u }' <<<"$1"
}

# compose_body <report-text> <failure-lines>
compose_body() {
printf '%s\n\n%s\n\n' "$1" "$failures_heading"
Expand Down
9 changes: 6 additions & 3 deletions hack/automation/report-failure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#
# Usage: report-failure.sh <job> <run-url> [--dry-run]
#
# Appends "- <date> <job> <run-url>" to the "## Automation failures" section
# Records "- <date> <job> <run-url>" in the "## Automation failures" section
# of the open "Core main drift" issue, creating the issue when none is open.
# Repeated failures of a job on the same date update its one line with the
# latest run and a count instead of adding a line per run.
# Also writes the line to the job summary.
set -euo pipefail
# shellcheck source=hack/automation/drift-issue.sh
Expand All @@ -18,7 +20,8 @@ for a in "$@"; do
case $a in --dry-run) dry=1 ;; *) args+=("$a") ;; esac
done
[ ${#args[@]} -eq 2 ] || { echo "usage: $0 <job> <run-url> [--dry-run]" >&2; exit 2; }
line="- $(date -u +%Y-%m-%d) ${args[0]} ${args[1]}"
today=$(date -u +%Y-%m-%d)
line="- $today ${args[0]} ${args[1]}"
[ -z "${GITHUB_STEP_SUMMARY:-}" ] || echo "Automation failure: $line" >>"$GITHUB_STEP_SUMMARY"

n=$(drift_issue_number)
Expand All @@ -30,7 +33,7 @@ else
report="No drift report yet; the next core-drift run fills this in."
failures=
fi
failures=$(printf '%s\n%s' "$failures" "$line" | sed '/^$/d')
failures=$(add_failure_line "$failures" "$today" "${args[0]}" "${args[1]}")
body=$(compose_body "$report" "$failures")

if [ "$dry" -eq 1 ]; then
Expand Down
11 changes: 11 additions & 0 deletions hack/automation/rpc-issues-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ rpc_count_declarations() {
print "$n\n"' "${1:?rpc_count_declarations needs a file}"
}

# rpc_bot_issues_url <repo> <bot-login> <state>: the REST path that lists
# the issues and pull requests bot-login opened in repo. Coverage issues are
# found by their creator and marker, not by the rpc-coverage label, so an
# issue whose label someone removed is still recognized (the next run adds
# the label back) instead of getting a duplicate.
rpc_bot_issues_url() {
local creator
creator=$(jq -rn --arg s "${2:?rpc_bot_issues_url needs the bot login}" '$s | @uri')
printf 'repos/%s/issues?creator=%s&state=%s&per_page=100\n' "${1:?rpc_bot_issues_url needs the repo}" "$creator" "${3:-all}"
}

# rpc_parse_exceptions <file>: print the entries of an exceptions list
# (hack/automation/rpc-exceptions.txt) as a JSON array of {key, reason}.
# Lines whose first non-blank character is "#" and blank lines are ignored.
Expand Down
25 changes: 25 additions & 0 deletions hack/automation/rpc-issues-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,5 +168,30 @@ else
fail "drift-links $(cat "$work/err")"
fi

# Coverage issues are listed by creator, not by label.
if [ "$(rpc_bot_issues_url ai-openshell/sdk-go 'ai-openshell-sdk-go[bot]' open)" = \
'repos/ai-openshell/sdk-go/issues?creator=ai-openshell-sdk-go%5Bbot%5D&state=open&per_page=100' ] &&
[ "$(rpc_bot_issues_url o/r bot)" = 'repos/o/r/issues?creator=bot&state=all&per_page=100' ]; then
echo "ok bot-issues-url"
else
fail "bot-issues-url: $(rpc_bot_issues_url ai-openshell/sdk-go 'ai-openshell-sdk-go[bot]' open)"
fi

# Repeated failures of a job on one date share one line with a count.
f0='- 2026-11-18 core-drift https://x/runs/1'
f1=$(add_failure_line "$f0" 2026-11-19 core-watch https://x/runs/2)
f2=$(add_failure_line "$f1" 2026-11-19 core-watch https://x/runs/3)
f3=$(add_failure_line "$f2" 2026-11-19 core-watch https://x/runs/4)
f4=$(add_failure_line "$f3" 2026-11-19 release-tag https://x/runs/5)
expected='- 2026-11-18 core-drift https://x/runs/1
- 2026-11-19 core-watch https://x/runs/4 (3 runs)
- 2026-11-19 release-tag https://x/runs/5'
if [ "$f4" = "$expected" ] && [ "$(add_failure_line '' 2026-11-19 core-watch https://x/runs/9)" = '- 2026-11-19 core-watch https://x/runs/9' ] &&
[ "$(failure_lines "$(compose_body report "$f4")")" = "$expected" ]; then
echo "ok failure-lines"
else
fail "failure-lines: $f4"
fi

[ "$failed" -eq 0 ] || { echo "rpc-issues tests failed" >&2; exit 1; }
echo "rpc-issues tests passed"
16 changes: 14 additions & 2 deletions hack/automation/rpc-issues.jq
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,26 @@ def auth_text:
+ (if .global_role then ", global role `\(.global_role)`" else "" end)
end;

def proto_block: "```proto\n" + . + "\n```";
# md_text: text from core's protos (doc comments) is data. A zero-width
# space keeps GitHub from turning "@name" into a mention and "#123" into a
# reference to an issue of this repository, and keeps "<!--" from hiding the
# rest of the body. It is invisible, also inside code spans, where an HTML
# entity would show literally.
def md_text: gsub("@"; "@\u200b") | gsub("#(?<d>[0-9])"; "#\u200b\(.d)") | gsub("<!--"; "<\u200b!--");

# proto_block: a fenced code block whose fence is longer than any backtick
# run in the source, so a proto comment cannot close it early.
def proto_block:
([scan("`+") | length] | max // 0) as $n
| ([range([3, $n + 1] | max)] | map("`") | join("")) as $f
| $f + "proto\n" + . + "\n" + $f;

def link_list: map("[`\(.path)`](\(.url))") | join(", ");

# One section per method: signature, comment, streaming kind, auth, messages.
def method_section($tag):
"## `\(.key)`\n\n"
+ (if (.comment // "") != "" then .comment + "\n\n" else "" end)
+ (if (.comment // "") != "" then (.comment | md_text) + "\n\n" else "" end)
+ "- Streaming: \(streaming_kind)\n"
+ "- Authorization: \(auth_text)\n"
+ "- Definition: [`proto/\(.file)`](\(.proto_url)) at core `\($tag)`\n"
Expand Down
7 changes: 4 additions & 3 deletions hack/automation/rpc-issues.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,13 @@ gather() {
rpc_parse_exceptions "${RPC_EXCEPTIONS:-hack/automation/rpc-exceptions.txt}" >"$work/exceptions.json" || exit 1
# The REST issue list, not gh issue list --label (the search index lags
# behind writes). Only issues the bot opened count, so a marker in
# someone else's issue cannot steer the automation.
retry_to "$work/issues.ndjson" gh api --paginate "repos/$sdk_repo/issues?labels=rpc-coverage&state=all&per_page=100" \
# someone else's issue cannot steer the automation; they are listed by
# creator, not by label, so removing the label does not cause a duplicate.
retry_to "$work/issues.ndjson" gh api --paginate "$(rpc_bot_issues_url "$sdk_repo" "$bot_login" all)" \
--jq '.[] | select(.pull_request == null)
| {number, state: (.state | ascii_upcase), title, body: (.body // ""),
labels: [.labels[].name], author: .user.login}' ||
die "cannot list the rpc-coverage issues of $sdk_repo"
die "cannot list the issues $bot_login opened in $sdk_repo"
rpc_bot_issues "$bot_login" "$work/issues.ndjson" >"$work/issues.json"

jq -n --arg repo "$sdk_repo" --arg core_repo "$core_repo" --arg tag "$tag" \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"action": "update",
"add_labels": [
"help wanted",
"rpc-coverage",
"rpc:ready"
],
"group": "method:OpenShell.ForwardTcp",
"number": 20
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
105 changes: 105 additions & 0 deletions hack/automation/testdata/rpc-issues/planner/label-removed/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"built": [
"OpenShell.GetSandbox",
"OpenShell.ForwardTcp"
],
"bump_branch_exists": true,
"core_repo": "NVIDIA/OpenShell",
"covered": [
"OpenShell.GetSandbox"
],
"exceptions": [],
"generated_files": [
"openshell.proto",
"datamodel.proto",
"sandbox.proto",
"options.proto"
],
"issues": [
{
"body": "<!-- rpc-coverage: kind=method service=OpenShell method=ForwardTcp first-seen=v0.1.9 methods=ForwardTcp -->\n\nCore `v0.2.0` has `OpenShell.ForwardTcp`, a user-facing RPC that the Go SDK does not wrap yet. First seen in core `v0.1.9`.\n\n**Buildable on `main`**: the generated bindings on the SDK's `main` already contain every method listed here.\n\n## `OpenShell.ForwardTcp`\n\nForwardTcp does something useful.\n\n- Streaming: unary\n- Authorization: `bearer`, scope `sandbox:read`, workspace role `user`\n- Definition: [`proto/openshell.proto`](https://github.com/NVIDIA/OpenShell/blob/v0.2.0/proto/openshell.proto#L10-L12) at core `v0.2.0`\n- Generated bindings on the SDK's `main`: yes\n\n```proto\nrpc ForwardTcp(ForwardTcpRequest) returns (ForwardTcpResponse) {}\n```\n\nRequest and response messages:\n\n```proto\nmessage ForwardTcpRequest {\n string name = 1;\n}\n```\n\n```proto\nmessage ForwardTcpResponse {}\n```\n\n## Where core implements it\n\n### `OpenShell.ForwardTcp`\n\n- Server (`crates/openshell-server/src`): [`crates/openshell-server/src/grpc/mod.rs`](https://github.com/NVIDIA/OpenShell/blob/v0.2.0/crates/openshell-server/src/grpc/mod.rs)\n- Rust SDK (`crates/openshell-sdk/src`): not found\n- TypeScript SDK (`sdk/typescript/src`): not found\n\n## Implementation brief\n\nCopy this block as the task description when you start the work.\n\n````text\nWrap the OpenShell.ForwardTcp RPC of OpenShell core in the OpenShell Go SDK (https://github.com/ai-openshell/sdk-go).\n\nCore version: NVIDIA/OpenShell at tag v0.2.0.\nBranch: start from main; its generated bindings already contain the methods.\n\nRead first:\n- AGENTS.md and CONTRIBUTING.md in the SDK repository: conventions, commands, and commit rules.\n- OpenShell.ForwardTcp: proto definition https://github.com/NVIDIA/OpenShell/blob/v0.2.0/proto/openshell.proto#L10-L12; core server: https://github.com/NVIDIA/OpenShell/blob/v0.2.0/crates/openshell-server/src/grpc/mod.rs\n- The pattern to follow: the sub-client in openshell/v1/service_client.go, its types in openshell/v1/types/service.go, its converter in openshell/v1/internal/converter/service.go, and its fake in openshell/v1/fake/service.go.\n\nDeliverables:\n- The method in openshell/v1, on the sub-client that fits it, behind its interface like the other sub-client methods.\n- Domain types in openshell/v1/types/ without proto imports.\n- Converters in openshell/v1/internal/converter/ that deep-copy slices and maps.\n- The fake implementation in openshell/v1/fake/.\n- Unit tests with bufconn and testify.\n- Documentation: a page under docs/src/api/ (like docs/src/api/services.md) with its entry in docs/src/SUMMARY.md, or an update of the existing page.\n\nDone when `mise run ci` passes. Use Conventional Commits and sign off every commit.\n````\n\n## About this issue\n\nThe RPC coverage automation (`hack/automation/rpc-issues.sh`, run by the hourly core-watch workflow) opened this issue and keeps it in sync with the newest core release tag.\nIt rewrites this description when the definition or the buildability changes, and closes the issue when the SDK covers every method listed here under `openshell/v1`, when core removes them or makes them internal, or when they are listed with a reason in [`hack/automation/rpc-exceptions.txt`](https://github.com/ai-openshell/sdk-go/blob/main/hack/automation/rpc-exceptions.txt).\nAn issue closed by hand stays closed. Reopen it by hand to keep it open while the automation considers the methods covered.",
"labels": [],
"last_actor_is_bot": null,
"last_event": null,
"number": 20,
"state": "OPEN",
"title": "t"
}
],
"max_new": 10,
"repo": "ai-openshell/sdk-go",
"rpcs": [
{
"auth_mode": "bearer",
"client_streaming": false,
"comment": "GetSandbox does something useful.",
"file": "openshell.proto",
"global_role": null,
"messages": [
{
"name": "openshell.v1.GetSandboxRequest",
"source": "message GetSandboxRequest {\n string name = 1;\n}"
},
{
"name": "openshell.v1.GetSandboxResponse",
"source": "message GetSandboxResponse {}"
}
],
"method": "GetSandbox",
"proto_url": "https://github.com/NVIDIA/OpenShell/blob/v0.2.0/proto/openshell.proto#L10-L12",
"request": "openshell.v1.GetSandboxRequest",
"response": "openshell.v1.GetSandboxResponse",
"rust_sdk_refs": [],
"scope": "sandbox:read",
"server_refs": [
{
"path": "crates/openshell-server/src/grpc/mod.rs",
"url": "https://github.com/NVIDIA/OpenShell/blob/v0.2.0/crates/openshell-server/src/grpc/mod.rs"
}
],
"server_streaming": false,
"service": "OpenShell",
"signature": "rpc GetSandbox(GetSandboxRequest) returns (GetSandboxResponse) {}",
"ts_sdk_refs": [],
"workspace_role": "user"
},
{
"auth_mode": "bearer",
"client_streaming": false,
"comment": "ForwardTcp does something useful.",
"file": "openshell.proto",
"global_role": null,
"messages": [
{
"name": "openshell.v1.ForwardTcpRequest",
"source": "message ForwardTcpRequest {\n string name = 1;\n}"
},
{
"name": "openshell.v1.ForwardTcpResponse",
"source": "message ForwardTcpResponse {}"
}
],
"method": "ForwardTcp",
"proto_url": "https://github.com/NVIDIA/OpenShell/blob/v0.2.0/proto/openshell.proto#L10-L12",
"request": "openshell.v1.ForwardTcpRequest",
"response": "openshell.v1.ForwardTcpResponse",
"rust_sdk_refs": [],
"scope": "sandbox:read",
"server_refs": [
{
"path": "crates/openshell-server/src/grpc/mod.rs",
"url": "https://github.com/NVIDIA/OpenShell/blob/v0.2.0/crates/openshell-server/src/grpc/mod.rs"
}
],
"server_streaming": false,
"service": "OpenShell",
"signature": "rpc ForwardTcp(ForwardTcpRequest) returns (ForwardTcpResponse) {}",
"ts_sdk_refs": [],
"workspace_role": "user"
}
],
"services_bound": [
"OpenShell"
],
"tag": "v0.2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
Loading