diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..1de1cc1 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +# The sdk team owns the SDK; OpenShell maintainers review as a fallback. +* @ai-openshell/sdk @ai-openshell/maintainers + +# CI and the scripts it runs with the bot token need an infra review. +/.github/ @ai-openshell/infra +/hack/automation/ @ai-openshell/infra diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..cd68170 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "weekly" + cooldown: + default-days: 7 + groups: + go-minor-and-patch: + update-types: ["minor", "patch"] + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + cooldown: + default-days: 7 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3338a78..67ff9ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,3 +36,22 @@ jobs: # buf fetches proto/ from NVIDIA/OpenShell at the pinned tag (public, no credentials). - name: Run CI pipeline run: mise run ci + + workflows: + name: workflows + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0 + with: + install: false + + - name: Install tools + run: mise install --locked actionlint shellcheck zizmor + + - name: Lint workflows + run: mise run workflows:check diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..e9bafc6 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +name: CodeQL + +on: + pull_request: + push: + branches: [main] + schedule: + - cron: "29 5 * * 1" + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: codeql-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + analyze: + name: CodeQL (go) + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + security-events: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 + with: + go-version-file: go.mod + + - name: Initialize CodeQL + uses: github/codeql-action/init@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + with: + languages: go + build-mode: manual + + - name: Build + run: go build ./... + + - name: Analyze + uses: github/codeql-action/analyze@24c54180a607b1449ed407dd24f251e4e9147c8d # v4.38.3 + with: + category: /language:go diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..2303477 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,60 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +name: docs + +on: + pull_request: + paths: ["docs/**", "mise.toml", "mise.lock", ".github/workflows/docs.yml"] + push: + branches: [main] + workflow_dispatch: + +permissions: + contents: read + +concurrency: + group: docs-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + build: + name: build + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - uses: jdx/mise-action@e6a8b3978addb5a52f2b4cd9d91eafa7f0ab959d # v4.2.0 + with: + install: false + + - name: Install mdbook + run: mise install --locked mdbook + + - name: Build + run: mise run docs:build + + - name: Upload Pages artifact + if: github.event_name != 'pull_request' + uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 + with: + path: docs/book + + deploy: + name: deploy + if: github.event_name != 'pull_request' + needs: build + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - id: deployment + uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..d24602d --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,28 @@ +# Agent Instructions + +The OpenShell Go SDK: module `github.com/ai-openshell/sdk-go`, a client for the +OpenShell gateway. See [CONTRIBUTING.md](CONTRIBUTING.md) for tasks and the +release model. + +## Commands + +- `mise run ci` runs the full pipeline (format check, lint, build, test, proto + check, conformance check, docs check). +- `mise run proto:gen` regenerates `proto/` from core at the tag pinned in + `buf.gen.yaml`. Never edit generated files by hand. + +## Code conventions + +- Domain types in `openshell/v1/types/` must not import proto packages. +- Converters in `openshell/v1/internal/converter/` deep-copy slices and maps at + boundaries. +- Tests use bufconn for in-process gRPC and testify for assertions. +- Test fixtures live in the `testdata/` directory of the package that reads + them. Never read files outside the module. + +## Commits + +- Use Conventional Commits and sign off every commit (`--signoff`). +- Never mention Claude or any AI agent in commits, pull request descriptions, or + issues (no author attribution, no Co-Authored-By, no "Generated with" + footers). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..742adac --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,54 @@ +# Contributing to the OpenShell Go SDK + +## Setup + +Install [mise](https://mise.jdx.dev/), then install the pinned tools: + +```shell +mise install --locked +``` + +`mise tasks` lists every task. The ones you need most: + +| Task | What it does | +|------|--------------| +| `mise run ci` | Everything CI runs: format check, lint, build, tests, proto check, conformance check, docs check | +| `mise run fmt` | Format the code | +| `mise run test` | Unit tests with the race detector | +| `mise run proto:gen` | Regenerate the bindings from core at the pinned tag | +| `mise run core:version` | Print the pinned core version | +| `mise run workflows:check` | Lint the GitHub workflows | +| `mise run docs:build` | Build the docs into `docs/book` | + +## Commits and pull requests + +- Use [Conventional Commits](https://www.conventionalcommits.org/): + `(): `. +- Sign off every commit (`git commit --signoff`) for the [Developer Certificate + of Origin](https://developercertificate.org/). +- Every change goes through a pull request with an approval from a code owner + who did not push last. + +## Bindings and core versions + +The bindings in `proto/` are generated from core's `proto/` at one core release +tag, the `tag:` line in `buf.gen.yaml`. Don't edit generated files; change the +pin and run `mise run proto:gen`. `mise run proto:check` fails when the +committed bindings don't match the pin. + +Shared test fixtures come from core's `sdk/conformance/` and are vendored next +to the tests that read them. `mise run conformance:check` compares them with +core at the pinned tag. + +SDK releases follow core releases: SDK `vX.Y.Z` is built from core `vX.Y.Z`, and +there are no SDK-only releases. + +## Core bumps and drift + +Automation watches core for new tags and opens a pull request that moves the +pin, labeled `core-bump` plus `stable` or `prerelease`. If a bump needs SDK +changes, push them to the same branch. Merging a bump to a stable tag tags the +SDK release. + +A nightly job checks core's `main` for breaking proto changes and RPCs the SDK +doesn't cover yet, and keeps one issue labeled `core-drift` up to date. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..0760136 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,15 @@ +# Security Policy + +## Reporting a vulnerability + +Report vulnerabilities in the OpenShell Go SDK privately through +[NVIDIA/OpenShell's private reporting +form](https://github.com/NVIDIA/OpenShell/security/advisories/new) and name +`ai-openshell/sdk-go` as the affected component. Do not disclose vulnerabilities +in public issues, discussions, or pull requests. + +The OpenShell security policy applies to this repository: the [report template, +review process, and coordinated +disclosure](https://github.com/NVIDIA/OpenShell/blob/main/SECURITY.md) are the +same. Private reporting directly on this repository will be enabled once its +process is set up; until then, use the form above. diff --git a/mise.lock b/mise.lock index 98fe920..a248096 100644 --- a/mise.lock +++ b/mise.lock @@ -2,6 +2,29 @@ lockfile_version = 3 +[[tools.actionlint]] +version = "1.7.12" +backend = "aqua:rhysd/actionlint" +specifiers = ["1.7.12"] + +[tools.actionlint."platforms.linux-arm64"] +checksum = "sha256:325e971b6ba9bfa504672e29be93c24981eeb1c07576d730e9f7c8805afff0c6" +url = "https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_arm64.tar.gz" +url_api = "https://api.github.com/repos/rhysd/actionlint/releases/assets/384924897" +provenance = "github-attestations" + +[tools.actionlint."platforms.linux-x64"] +checksum = "sha256:8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8" +url = "https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_linux_amd64.tar.gz" +url_api = "https://api.github.com/repos/rhysd/actionlint/releases/assets/384924896" +provenance = "github-attestations" + +[tools.actionlint."platforms.macos-arm64"] +checksum = "sha256:aba9ced2dee8d27fecca3dc7feb1a7f9a52caefa1eb46f3271ea66b6e0e6953f" +url = "https://github.com/rhysd/actionlint/releases/download/v1.7.12/actionlint_1.7.12_darwin_arm64.tar.gz" +url_api = "https://api.github.com/repos/rhysd/actionlint/releases/assets/384924893" +provenance = "github-attestations" + [[tools.buf]] version = "1.72.0" backend = "aqua:bufbuild/buf" @@ -62,6 +85,41 @@ version = "1.36.11" backend = "go:google.golang.org/protobuf/cmd/protoc-gen-go" specifiers = ["1.36.11"] +[[tools.mdbook]] +version = "0.5.4" +backend = "aqua:rust-lang/mdBook" +specifiers = ["0.5.4"] + +[tools.mdbook."platforms.linux-x64"] +checksum = "sha256:3f28de05dafca9d0f2eab99c662116b0e37b89b1d96a08f8f430b9eeae958cd7" +url = "https://github.com/rust-lang/mdBook/releases/download/v0.5.4/mdbook-v0.5.4-x86_64-unknown-linux-gnu.tar.gz" +url_api = "https://api.github.com/repos/rust-lang/mdBook/releases/assets/468209394" + +[tools.mdbook."platforms.macos-arm64"] +checksum = "sha256:a47d7bf0d5d670cff9ee6cce95537cbeb62dc10704d9e7131ffbd13e2b59a5de" +url = "https://github.com/rust-lang/mdBook/releases/download/v0.5.4/mdbook-v0.5.4-x86_64-apple-darwin.tar.gz" +url_api = "https://api.github.com/repos/rust-lang/mdBook/releases/assets/468210169" + +[[tools.shellcheck]] +version = "0.11.0" +backend = "aqua:koalaman/shellcheck" +specifiers = ["0.11.0"] + +[tools.shellcheck."platforms.linux-arm64"] +checksum = "sha256:12b331c1d2db6b9eb13cfca64306b1b157a86eb69db83023e261eaa7e7c14588" +url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.aarch64.tar.xz" +url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056934" + +[tools.shellcheck."platforms.linux-x64"] +checksum = "sha256:8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198" +url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.linux.x86_64.tar.xz" +url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056942" + +[tools.shellcheck."platforms.macos-arm64"] +checksum = "sha256:56affdd8de5527894dca6dc3d7e0a99a873b0f004d7aabc30ae407d3f48b0a79" +url = "https://github.com/koalaman/shellcheck/releases/download/v0.11.0/shellcheck-v0.11.0.darwin.aarch64.tar.xz" +url_api = "https://api.github.com/repos/koalaman/shellcheck/releases/assets/279056932" + [[tools.yq]] version = "4.53.6" backend = "aqua:mikefarah/yq" @@ -84,3 +142,26 @@ checksum = "sha256:cceb0b8d71ea5294334121f8429f33f92b920e7217d904a2f9f35443968ac url = "https://github.com/mikefarah/yq/releases/download/v4.53.6/yq_darwin_arm64" url_api = "https://api.github.com/repos/mikefarah/yq/releases/assets/522028033" provenance = "cosign" + +[[tools.zizmor]] +version = "1.32.0" +backend = "aqua:zizmorcore/zizmor" +specifiers = ["1.32.0"] + +[tools.zizmor."platforms.linux-arm64"] +checksum = "sha256:cb152b207f815116d7fa1c1ee4614f61578803351395052908095e79adfd9fd0" +url = "https://github.com/zizmorcore/zizmor/releases/download/v1.32.0/zizmor-aarch64-unknown-linux-gnu.tar.gz" +url_api = "https://api.github.com/repos/zizmorcore/zizmor/releases/assets/703541931" +provenance = "github-attestations" + +[tools.zizmor."platforms.linux-x64"] +checksum = "sha256:bb110cc765eca9cd7efb2e284a956be5974c60027b0970f16397d86208a9957b" +url = "https://github.com/zizmorcore/zizmor/releases/download/v1.32.0/zizmor-x86_64-unknown-linux-gnu.tar.gz" +url_api = "https://api.github.com/repos/zizmorcore/zizmor/releases/assets/703541932" +provenance = "github-attestations" + +[tools.zizmor."platforms.macos-arm64"] +checksum = "sha256:6efed18c4539a663fd3c851a2be9533fd8456c4e646d9416206da059154a0d3c" +url = "https://github.com/zizmorcore/zizmor/releases/download/v1.32.0/zizmor-aarch64-apple-darwin.tar.gz" +url_api = "https://api.github.com/repos/zizmorcore/zizmor/releases/assets/703541933" +provenance = "github-attestations" diff --git a/mise.toml b/mise.toml index 6783d6a..11d79ce 100644 --- a/mise.toml +++ b/mise.toml @@ -19,6 +19,10 @@ yq = "4.53.6" "go:google.golang.org/protobuf/cmd/protoc-gen-go" = "1.36.11" "go:google.golang.org/grpc/cmd/protoc-gen-go-grpc" = "1.6.2" "go:golang.org/x/tools/cmd/goimports" = "0.48.0" +actionlint = "1.7.12" +shellcheck = "0.11.0" +zizmor = "1.32.0" +mdbook = "0.5.4" [tasks.test] description = "Run unit tests with coverage" @@ -224,3 +228,14 @@ fi echo "Proto check passed: generated files match core $(yq -r '.inputs[0].tag' buf.gen.yaml)." """ + +[tasks."workflows:check"] +description = "Lint GitHub workflows with actionlint (with shellcheck) and zizmor" +run = [ + "actionlint", + "zizmor --offline --min-severity medium .github", +] + +[tasks."docs:build"] +description = "Build the mdbook docs into docs/book" +run = "mdbook build docs"