diff --git a/.cursor/rules/pstack-models.mdc b/.cursor/rules/pstack-models.mdc new file mode 100644 index 00000000..db9086e2 --- /dev/null +++ b/.cursor/rules/pstack-models.mdc @@ -0,0 +1,14 @@ +--- +description: pstack per-role model choices (overrides skill defaults) +alwaysApply: true +--- +# budget: small (medium) +feature, refactoring: claude-opus-5-5-medium +bug-fix: claude-opus-5-5-medium +perf-issue: claude-opus-5-5-medium +hillclimb: claude-opus-5-5-medium +judgment and prose: claude-opus-5-5-medium +arena runners: claude-fable-5-2-low, claude-opus-5-5-low, gemini-4-carbon-low +arena cross-judge pool: claude-opus-5-5-low, gemini-4-carbon-low +swarm workers: claude-opus-5-5-low +interrogate reviewers: claude-fable-5-2-low, claude-opus-5-5-low, gemini-4-carbon-low diff --git a/.github/workflows/commit-authorship.yml b/.github/workflows/commit-checks.yml similarity index 55% rename from .github/workflows/commit-authorship.yml rename to .github/workflows/commit-checks.yml index ab4fff1b..c9b71e46 100644 --- a/.github/workflows/commit-authorship.yml +++ b/.github/workflows/commit-checks.yml @@ -1,4 +1,4 @@ -name: Commit Authorship +name: Commit Checks on: pull_request: @@ -7,9 +7,9 @@ permissions: contents: read jobs: - check-authorship: - name: Check commit authorship - runs-on: [self-hosted, Linux] + check-commits: + name: Check commits + runs-on: ubuntu-latest steps: - name: Check out repository @@ -24,3 +24,11 @@ jobs: BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: scripts/ci/check-authorship.sh "$BASE_SHA" "$HEAD_SHA" + + - name: Check GitHub Verified badge on each commit + env: + BASE_SHA: ${{ github.event.pull_request.base.sha }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: scripts/ci/check-commit-verification.sh "$BASE_SHA" "$HEAD_SHA" diff --git a/.gitignore b/.gitignore index fd6fabe9..45eeb39c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,32 +1,24 @@ -# Build artifacts +artifacts/ bin/ dist/ -# Scratch dir for local validation / temporary files .tmp/ tmp/ -# Local environment .env .env.* !.env.example -# OS/editor files .DS_Store .idea/ .vscode/ -# AI files -.cursor/ -.claude/ -AGENTS.md -CLAUDE.md - # Vite/React build output for the embedded Web UI. The placeholder # index.html is tracked so go:embed has at least one match on a # fresh clone; `make frontend` overwrites it with the real bundle. # See internal/ui/assets.go. # +# TODO: Create a github check for this # DO NOT commit a real Vite build's index.html over the placeholder: the # hashed assets/*.js and *.css it references are git-ignored, so a checkout # would point at files that don't exist. Keep the DEVKIT_FRONTEND_PLACEHOLDER @@ -35,10 +27,7 @@ internal/ui/dist/* !internal/ui/dist/index.html .worktrees/ -# worktrunk configs .config/wt.toml -# workspace files *.code-workspace .omo/ -/artifacts/ diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 00000000..2188ebaa --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,10 @@ +# Agent instructions + +Follow [`CONTRIBUTING.md`](CONTRIBUTING.md). It is the source of truth for project conventions, including the no-comments policy. + +## Agent workflow + +- Work on a feature branch off `main`; do not commit to `main`. +- Match this repo's commit checks CI: human author/committer (no AI-tool identities or AI `Co-authored-by` trailers), and every commit GitHub-**Verified**. Do not leave Cursor-signed commits on a human author (`Unverified` / `unknown_key`); the human author must re-sign with their GitHub signing key before merge (see CONTRIBUTING "Commit signatures"). +- Before review, run `/no-comments` on the diff. +- Prefer the smallest change that satisfies CONTRIBUTING; do not expand scope. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e225ae06..b6114c44 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -110,7 +110,7 @@ When the work spans both: - **Mirror the verbs.** If the UI gets `POST /api/instances/{name}/containers/{c}/restart`, the CLI should get `dpm localnet container restart `. The CLI name is a wrapper around the same handler logic; both pass through the same shared function. - **Mirror the guards.** If the Web UI's pre-flight gate refuses to start a Splice 0.6.4 instance on a 4 GiB host, `dpm localnet up --version 0.6.4` must refuse it for the same reason. Don't let one surface be lenient where the other is strict. -**When you can't reach parity in the same PR**, file a follow-up issue and add a `// TODO(#issue): CLI parity — ` comment at the divergence point so reviewers can see it. Never close out a feature as "done" while one surface is silently missing it. +**When you can't reach parity in the same PR**, file a follow-up issue and link it from the PR. Never close out a feature as "done" while one surface is silently missing it. ### Docker Compose teardown must be `-p`-only @@ -158,6 +158,21 @@ Rules: - Cobra command builders return `*cobra.Command` - `App` struct uses dependency injection for `io.Writer` (testability) +### Comments + +Do not add comments by default. No narration or why-comments. + +Allowed only: + +- Legal / license headers +- Public API doc comments that define a contract +- Issue/RFC links that state a constraint code cannot express +- Behavior forced by an external dependency, platform, vendor, or protocol we cannot reshape + +Encode other constraints in types, names, tests, or CI. + +Rationale: [Lauren Tan (@poteto) on comments](https://x.com/poteto/status/2110758788525621282). + ## Architecture Notes - **Entry point:** `cmd/canton-devkit/main.go` @@ -167,7 +182,7 @@ Rules: ## CI Pipeline -- All CI jobs (`test`, `mockup-syntax`, `lint`, `frontend`) run on `[self-hosted, Linux]` runners on every PR and push to `main`. +- Build CI jobs (`test`, `mockup-syntax`, `lint`, `frontend`) run on `[self-hosted, Linux]` runners on every PR and push to `main`. Commit checks (`Check commits`: authorship + GitHub Verified) run on `ubuntu-latest` on every PR. - macOS / Windows CI was removed in commit `9a0dae1` — cross-platform validation now lives in `.github/workflows/release.yml`. - All GitHub Actions must be SHA-pinned (no floating tags like `@v4`) @@ -176,6 +191,26 @@ Rules: - Commit messages must explain **why** the change is needed - Keep messages clear and informative +## Commit signatures + +Every commit on a pull request must show as **Verified** on GitHub. CI runs +`scripts/ci/check-commit-verification.sh` as part of workflow **Check commits**. + +- Sign with a GPG or SSH key registered to the commit author under + GitHub → Settings → SSH and GPG keys (**Signing keys**, not only Authentication). +- Enable signing locally (`git config commit.gpgsign true`, and for SSH: + `gpg.format ssh` + `user.signingkey` pointing at your public key). +- **Unverified** means the commit is signed, but GitHub does not trust the key + for that author (common reason: `unknown_key`). Cursor / Cloud Agent SSH + signatures on human-authored commits produce this badge — re-sign as the + author before review: + +```sh +# After your signing key is registered on GitHub: +git rebase --exec 'git commit --amend --no-edit -S' origin/main +git push --force-with-lease +``` + ## PR Checklist Before submitting: @@ -185,4 +220,4 @@ Before submitting: 3. No test coverage regression (check with `go tool cover`) 4. Relevant documentation added/updated 5. PR title is clear and understandable -6. **CLI ↔ Web UI parity:** if the change touches a user-facing feature, both surfaces are updated (or a follow-up issue is filed with a `TODO(#issue): CLI parity` / `TODO(#issue): UI parity` comment at the divergence point). See "CLI ↔ Web UI parity" rule above. +6. **CLI ↔ Web UI parity:** if the change touches a user-facing feature, both surfaces are updated (or a follow-up issue is filed and linked from the PR). See "CLI ↔ Web UI parity" rule above. diff --git a/scripts/ci/check-commit-verification.sh b/scripts/ci/check-commit-verification.sh new file mode 100755 index 00000000..2961c052 --- /dev/null +++ b/scripts/ci/check-commit-verification.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# Fail if any commit in a range is not GitHub-verified. +# GitHub's Commits API is authoritative; local git verify-commit is not. +# +# Usage: check-commit-verification.sh [head-ref] +# check-commit-verification.sh + +set -euo pipefail + +usage() { + echo "usage: $0 [head-ref]" >&2 + echo " $0 " >&2 + exit 2 +} + +[ "$#" -ge 1 ] || usage + +if [ "$#" -eq 1 ]; then + range="$1" +else + range="$1..${2:-HEAD}" +fi + +: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY must be set (owner/repo)}" + +if ! command -v jq >/dev/null 2>&1; then + echo "jq is required" >&2 + exit 2 +fi + +commits="$(git rev-list --no-merges "$range")" + +if [ -z "$commits" ]; then + echo "OK: no commits in range $range" + exit 0 +fi + +api="https://api.github.com/repos/${GITHUB_REPOSITORY}/commits" +auth_args=() +if [ -n "${GITHUB_TOKEN:-}" ]; then + auth_args=(-H "Authorization: Bearer ${GITHUB_TOKEN}") +fi + +violations=0 + +for sha in $commits; do + subject="$(git show -s --format='%s' "$sha")" + payload="$( + curl -sS \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "${auth_args[@]}" \ + "${api}/${sha}" + )" + + if ! printf '%s' "$payload" | jq -e '.commit.verification' >/dev/null 2>&1; then + violations=$((violations + 1)) + echo "FAILED: ${sha} ${subject}" + echo " could not read commit.verification from GitHub API" + msg="$(printf '%s' "$payload" | jq -r '.message // empty' 2>/dev/null || true)" + [ -n "$msg" ] && echo " api: ${msg}" + continue + fi + + verified="$(printf '%s' "$payload" | jq -r '.commit.verification.verified')" + reason="$(printf '%s' "$payload" | jq -r '.commit.verification.reason')" + + if [ "$verified" != "true" ]; then + violations=$((violations + 1)) + echo "FAILED: ${sha} ${subject}" + echo " verified: false (reason: ${reason})" + fi +done + +if [ "$violations" -gt 0 ]; then + echo + echo "${violations} commit(s) are not GitHub-verified in range ${range}." + echo "Sign each commit with a GPG or SSH key registered to the commit" + echo "author on GitHub (Settings → SSH and GPG keys → Signing keys), then" + echo "force-push. A Cursor/Cloud-Agent SSH signature on a human-authored" + echo "commit yields reason=unknown_key (Unverified) — re-sign as the author." + exit 1 +fi + +echo "OK: all $(echo "$commits" | wc -l | tr -d ' ') commit(s) are GitHub-verified."