diff --git a/.dz/maintainer/reviewer.md b/.dz/maintainer/reviewer.md index 45a6c7f..f5d67e3 100644 --- a/.dz/maintainer/reviewer.md +++ b/.dz/maintainer/reviewer.md @@ -1,7 +1,7 @@ # Reviewer instructions — developerz-ai/fast_rspec > Read by the developerz.ai reviewer at EVERY review of this repository, at the reviewed -> commit, as this repo's own layer of the reviewer's prompt — established by dz-runner setup mode. +> commit, as this repo's own layer of the reviewer's prompt. > It refines the platform rules (a finding is cited or withheld; the bot always discloses) > and never overrides them. Edit freely; keep it under 12,000 characters — past that it is cut. diff --git a/.dz/onboarding/scorecard.md b/.dz/onboarding/scorecard.md index c706371..bd5e003 100644 --- a/.dz/onboarding/scorecard.md +++ b/.dz/onboarding/scorecard.md @@ -1,8 +1,7 @@ # AI-first scorecard -> Written by the developerz.ai maintainer agent — established by dz-runner setup mode. Each onboarding run rewrites this file whole; the latest run wins, and the same card is stored on the platform. +> Written by the developerz.ai maintainer agent. Each onboarding run rewrites this file whole; the latest run wins, and the same card is stored on the platform. -- Run: `run_5c8b684df57a49a9b94b756bdadfcddf` - Computed: 2026-10-31T21:55:27.177Z - Proof: **proved** — every command ran green at head. - Score: 13 of 15 items ok diff --git a/.env.example b/.env.example index 87b4fb7..bd592df 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,4 @@ -# .env.example — established by dz-runner setup mode. +# .env.example — owned by this repository's maintainers. # NAMES only. Copy to `.env`, fill each value there, and never commit that file. -# dormant: only `.mcp.json` uses it for the developerz MCP server; setup, dev and check read no credential (optional) -DEVELOPERZ_API_KEY= +# setup, dev and check read no credential. diff --git a/.githooks/pre-commit b/.githooks/pre-commit index c3b9929..f1e5c0e 100755 --- a/.githooks/pre-commit +++ b/.githooks/pre-commit @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# pre-commit gate — established by dz-runner setup mode. Runs the SAME +# pre-commit gate — owned by this repository's maintainers. Runs the SAME # `bin/check` CI runs, so a commit that would fail CI fails here first. # ACTIVATE IT (once, per clone): git config core.hooksPath .githooks set -euo pipefail diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 400df82..245e179 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,6 +30,14 @@ jobs: - uses: ruby/setup-ruby@v1 with: { ruby-version: '3.4', bundler-cache: true } - run: bundle exec rubocop --parallel + - name: Public tree + env: + # The public-tree guard's private words (bin/check-public-tree). Required on this + # repository's own runs, where the secret exists; forks and Dependabot get none. + PUBLIC_TREE_PRIVATE_WORDS: ${{ secrets.PUBLIC_TREE_PRIVATE_WORDS }} + PUBLIC_TREE_PRIVATE_WORDS_REQUIRED: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]' && '1' || '' }} + working-directory: . + run: bash bin/check-public-tree --self-test && bash bin/check-public-tree test: name: Test / ${{ matrix.ruby }} diff --git a/.mcp.json b/.mcp.json index cfd18fb..53da2d8 100644 --- a/.mcp.json +++ b/.mcp.json @@ -4,22 +4,6 @@ "type": "stdio", "command": "codegraph", "args": ["serve", "--mcp"] - }, - "developerz": { - "type": "http", - "url": "https://mcp.developerz.ai/v1/mcp", - "headers": { - "Authorization": "Bearer ${DEVELOPERZ_API_KEY}" - } - }, - "sentry-mcp": { - "type": "stdio", - "command": "bunx", - "args": ["@sentry/mcp-server"], - "env": { - "SENTRY_ACCESS_TOKEN": "${SENTRY_ACCESS_TOKEN}", - "SENTRY_HOST": "${SENTRY_HOST}" - } } } } diff --git a/bin/check-public-tree b/bin/check-public-tree new file mode 100755 index 0000000..de8c4ae --- /dev/null +++ b/bin/check-public-tree @@ -0,0 +1,153 @@ +#!/usr/bin/env bash +# The public tree names nothing private. This repository is public, so every tracked file is a +# public document: no host on our own domain beyond the public site, no private repository or its +# tracker, no one's home directory, no name of the setup mode that once wrote agent files, and none +# of the private words. +# +# The private words are never in this file, whole or in parts: fragments joined in a public file +# are the word to anyone who reads it. They come from the PUBLIC_TREE_PRIVATE_WORDS CI secret +# (comma- or newline-separated). A run without it says it skipped them; this repository's own CI +# runs set PUBLIC_TREE_PRIVATE_WORDS_REQUIRED=1, where an empty secret fails. The setup mode's name +# is already public, so it is assembled here. +# +# Reads `git ls-files`, proves it read this file and counts what it read. A failure names the file +# and the rule, never the matched text: CI logs are public. `--self-test` proves each rule fires. +# +# bin/check-public-tree [--self-test] +set -euo pipefail + +repo_root=$(cd "$(dirname "$0")/.." && pwd -P) +self=bin/check-public-tree +min_tracked=200 +domain_re='developerz\.ai' +org=developerz-ai +public_repos=" ai-army ai-designer ai-gaming-agent-mcp ai-task-master bun-on-rails cairn claude-and-conquer claude-task-master claudes db-mcp-gateway fast_rspec gold-standards-in-ai magik mcp-ssh mini multi-ai-router nexus-engine open-mmorpg open-remote-ssh-tmux research tessera ts23d ui-debugger-mcp ultimate universal-lsp wurk " +p1=dz +p2=runner +setup_re="${p1}[-_ ]?${p2}" +tracker_re="(^|[^A-Za-z0-9_./-])(infrastructure|${domain_re}|${p1}) ?#[0-9]" +home_re='(^|[^A-Za-z0-9_.-])/(home|Users)/[A-Za-z0-9_.-]+' +home_ok_re='/(home|Users)/(runner|user|app)([^A-Za-z0-9_.-]|$)' + +# The rules one text breaks, one per line; never the matched text. +violations() { + local text=$1 words_file=$2 host name hit homes + while IFS= read -r host; do + [[ -z $host ]] && continue + host=$(printf '%s' "$host" | tr '[:upper:]' '[:lower:]') + if [[ $host != "www.developerz.ai" ]]; then + echo 'internal host on our own domain' + break + fi + done < <(printf '%s' "$text" | grep -oiE "([a-z0-9-]+\.)+${domain_re}" || true) + grep -qiE "$setup_re" <<< "$text" && echo 'setup-mode name' + # Captured first: under pipefail an early-exiting `grep -q` would SIGPIPE its producer. + homes=$(grep -oE "$home_re" <<< "$text" || true) + if [[ -n $homes ]] && grep -vqE "$home_ok_re" <<< "$homes"; then + echo "someone's home directory" + fi + hit=0 + while IFS= read -r name; do + [[ -z $name ]] && continue + name=$(printf '%s' "${name##*/}" | tr '[:upper:]' '[:lower:]') + name=${name%.git} + name=${name%%.} + [[ $public_repos == *" $name "* ]] || hit=1 + done < <(printf '%s' "$text" | grep -oiE "(github\.com/|raw\.githubusercontent\.com/|api\.github\.com/repos/|^|[^A-Za-z0-9_./@-])${org}/[A-Za-z0-9_.-]+" | grep -oiE "${org}/[A-Za-z0-9_.-]+" || true) + if [[ $hit -eq 1 ]] || grep -qiE "$tracker_re" <<< "$text"; then + echo 'private repository' + fi + if [[ -s $words_file ]] && grep -qiF -f "$words_file" <<< "$text"; then + echo 'private word (from the secret)' + fi + return 0 +} + +words_file=$(mktemp "${TMPDIR:-/tmp}/public-tree.XXXXXXXX") +trap 'rm -f -- "$words_file"' EXIT +printf '%s' "${PUBLIC_TREE_PRIVATE_WORDS:-}" | tr ',' '\n' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' | grep -v '^$' > "$words_file" || true + +if [[ ${1:-} == --self-test ]]; then + fails=0 + expect() { # expect [words] + local want=$1 text=$2 words=${3:-} wf got + wf=$(mktemp "${TMPDIR:-/tmp}/public-tree.XXXXXXXX") + printf '%s' "$words" | tr ',' '\n' > "$wf" + got=$(violations "$text" "$wf" | tr '\n' '|' | sed 's/|$//') + rm -f -- "$wf" + if [[ $got != "$want" ]]; then + printf 'check-public-tree self-test: expected [%s], got [%s]\n' "$want" "$got" >&2 + fails=$((fails + 1)) + fi + } + expect 'internal host on our own domain' "url: https://mcp.developerz.""ai/v1" + expect '' "see https://www.developerz.ai" + expect 'setup-mode name' "a ${p1^^}-${p2^^} box" + expect "someone's home directory" "cd /ho""me/someone/src" + expect '' "runs-on: /home/runner/work" + expect 'private repository' "see ${org}/vault#12" + expect 'private repository' "(${p1}#1026)" + expect '' "${org}/gold-standards-in-ai#3, github.com/${org}/wurk" + expect '' "* @${org}/admin (a team, not a repository)" + expect 'private repository' "https://raw.githubusercontent.com/${org}/vault/main/x" + expect 'private repository' "https://api.github.com/repos/${org}/vault" + expect 'private word (from the secret)' "# runs on QUIMTEL" "quimtel,zorblax.io" + expect '' "zorblax-io and quim" "quimtel,zorblax.io" + # A match at the top of a file larger than a pipe buffer must still fire (no SIGPIPE under pipefail). + big=$(printf '%0200000d' 0) + expect 'setup-mode name' "${p1}-${p2} +$big" + expect 'private word (from the secret)' "quimtel +$big" "quimtel" + expect 'private repository' "(${p1}#1026) +$big" + # CI must pass the secret and the required flag on live (uncommented) lines: deleting, + # commenting out or weakening either would switch the private-word check off silently. + ci=$repo_root/.github/workflows/ci.yml + # The exact condition: a weaker one (`false && '1'`, a renamed repo check) never sets the flag. + required_line="PUBLIC_TREE_PRIVATE_WORDS_REQUIRED: \${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && github.actor != 'dependabot[bot]' && '1' || '' }}" + if ! grep -qE '^[[:space:]]+PUBLIC_TREE_PRIVATE_WORDS: \$\{\{ secrets\.PUBLIC_TREE_PRIVATE_WORDS \}\}[[:space:]]*$' "$ci" \ + || ! grep -qxF "$required_line" <<< "$(sed 's/^[[:space:]]*//; s/[[:space:]]*$//' "$ci")"; then + echo 'check-public-tree self-test: ci.yml does not pass the secret and the required flag' >&2 + fails=$((fails + 1)) + fi + if [[ $fails -ne 0 ]]; then echo ' fix: bash bin/check-public-tree --self-test # the failing fixture is named above' >&2; exit 1; fi + echo 'check-public-tree self-test: every rule fires' + exit 0 +fi + +if [[ ! -s $words_file ]]; then + if [[ ${PUBLIC_TREE_PRIVATE_WORDS_REQUIRED:-} == 1 ]]; then + echo 'check-public-tree: PUBLIC_TREE_PRIVATE_WORDS is empty, and PUBLIC_TREE_PRIVATE_WORDS_REQUIRED=1 says this run must check the private words' >&2 + echo ' fix: set the PUBLIC_TREE_PRIVATE_WORDS repository secret (an admin), or run without PUBLIC_TREE_PRIVATE_WORDS_REQUIRED locally' >&2 + exit 1 + fi + echo 'check-public-tree: PUBLIC_TREE_PRIVATE_WORDS is unset, private words not checked' >&2 +fi + +[[ $(git -C "$repo_root" rev-parse --show-toplevel) == "$repo_root" ]] || { echo "check-public-tree: git answers for another repository's tree" >&2; exit 1; } +mapfile -d '' files < <(git -C "$repo_root" ls-files -z) +# A here-string, not a pipe: under pipefail an early \`grep -q\` match would SIGPIPE a long listing. +grep -qxF "$self" <<< "$(printf '%s\n' "${files[@]}")" || { echo 'check-public-tree: the scan does not see this file, so its root is wrong' >&2; exit 1; } +read=0 +failures=0 +for path in "${files[@]}"; do + full=$repo_root/$path + [[ -f $full ]] || continue + grep -qI . "$full" 2>/dev/null || continue + read=$((read + 1)) + while IFS= read -r rule; do + [[ -z $rule ]] && continue + printf '%s: %s\n' "$path" "$rule" >&2 + failures=$((failures + 1)) + done < <(violations "$(cat "$full")" "$words_file") + # The path is published too: a file named after a private word or repository is a finding. + while IFS= read -r rule; do + [[ -z $rule ]] && continue + printf '%s: %s (in the path)\n' "$path" "$rule" >&2 + failures=$((failures + 1)) + done < <(violations "$path" "$words_file") +done +echo "check-public-tree: read $read of ${#files[@]} tracked files, $(wc -l < "$words_file" | tr -d ' ') private words" >&2 +[[ $read -ge $min_tracked ]] || { echo "check-public-tree: read only $read tracked files" >&2; exit 1; } +[[ $failures -eq 0 ]] || { echo "check-public-tree: $failures finding(s); rule per file, value withheld" >&2; echo " fix: remove the reference from each file named above, then: bash bin/check-public-tree" >&2; exit 1; } diff --git a/bin/dev b/bin/dev index 6d4c81a..613a117 100755 --- a/bin/dev +++ b/bin/dev @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# one-command dev — established by dz-runner setup mode. One command; adjust as the repo grows. +# one-command dev — owned by this repository's maintainers. One command; adjust as the repo grows. set -euo pipefail cd "$(dirname "$0")/../apps/fast-rspec" bundle exec rake test diff --git a/bin/stop b/bin/stop index c690dae..9440a8a 100755 --- a/bin/stop +++ b/bin/stop @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# one-command stop, run by developerz.ai when a session ends — established by dz-runner setup mode. One command; adjust as the repo grows. +# one-command stop, run by developerz.ai when a session ends — owned by this repository's maintainers. One command; adjust as the repo grows. set -euo pipefail cd "$(dirname "$0")/.." # Nothing detected to stop (no compose file at the repo root). Replace with the command