From 05c92ea0a7e059e73ee712ba5741a8958b779d35 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 05:19:45 +0000 Subject: [PATCH 1/2] Add a CodeRabbit config tailored to the repo Skip the prebuilt Graphviz binaries and staging/ in reviews, add per-path review instructions (Foundation-free Swift layer, C bridge NULL handling and WASI limits, serialized Swift Testing suites, portable scripts, workflow token hygiene, consistent Graphviz pins and checksums), drop summary extras, turn the docstring gate off and add two advisory checks: bundled Graphviz consistency and public API break disclosure. .coderabbit.yaml steers a review agent, so it joins CODEOWNERS and the hygiene check. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QehuQ55Dedo7Xa3rY9xRgA --- .coderabbit.yaml | 105 ++++++++++++++++++++++++++++++++++++++++ .github/CODEOWNERS | 3 +- scripts/hygiene.test.sh | 4 +- 3 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 .coderabbit.yaml diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 0000000..cf6547d --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,105 @@ +# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json +# CodeRabbit review settings for SwiftGraphviz. CLAUDE.md is picked up as review +# guidelines automatically; the instructions below add what matters per path. +language: en-US + +reviews: + profile: chill + request_changes_workflow: false # single maintainer; checks stay advisory + high_level_summary: true + poem: false + in_progress_fortune: false + sequence_diagrams: false + related_prs: true + auto_review: + enabled: true + auto_incremental_review: true + drafts: false + + # The prebuilt libraries are tens of MB of binaries and generated headers. Nothing in + # them is reviewable; their integrity is checked by scripts/check-artifacts.sh in CI. + path_filters: + - "!Graphviz.xcframework/**" + - "!CGraphviz.artifactbundle/**" + - "!CGraphvizWasm.artifactbundle/**" + - "!staging/**" # parked reference code, not built + + path_instructions: + - path: "Sources/SwiftGraphviz/**/*.swift" + instructions: | + Public Swift API over the Graphviz C library; VGraph and other apps depend on it. + - The layer must stay Foundation-free so it builds for wasm32-wasip1 and under + Embedded Swift. Flag any `import Foundation`, Foundation types or + existential-heavy code that Embedded Swift rejects. CoreGraphics bridging belongs + only in GVGeometry+Apple.swift behind `#if canImport(CoreGraphics)`. + - GVGraph/GVNode/GVEdge/GVCluster are raw `UnsafeMutablePointer`s. Check for + use after `agclose`/`gvFreeLayout`, reading layout data before a layout ran, + and C strings whose lifetime ends before Graphviz copies them. + - Units: Graphviz uses 72 points per inch; node width/height come back in inches. + Flag mixed-up units. + - Call out removed or renamed public API and changed defaults as breaking. + - path: "Sources/GraphvizBridge/**" + instructions: | + Thin C bridge that turns Graphviz macros into callable functions. It is compiled + for macOS, iOS, Linux and wasm32-wasip1 (see wasm_compat.h, wasi_compat.c). + Check NULL handling of every pointer coming from Graphviz (a NULL deref in + agUnflatten has happened before), integer overflow and signedness, and anything + not available under WASI (threads, dlopen, signals, filesystem assumptions). + Plugins are registered statically; no dynamic plugin loading. + - path: "Tests/**/*.swift" + instructions: | + Swift Testing (`import Testing`), not XCTest. The Graphviz context is global and + not thread-safe, so every suite must be nested under the `.serialized` root suite + `GraphvizTests`; flag a new top-level @Suite or test outside it. Prefer asserting + on real layout values over "does not crash". + - path: "**/*.sh" + instructions: | + Scripts run on macOS (BSD userland) and Linux (GNU) and in CI containers. Flag + GNU-only or BSD-only flags (sed -i, readlink -f, date, stat), unquoted variables, + and missing error handling. No personal or machine-specific absolute paths (scripts/hygiene.test.sh enforces this). + scripts/*.test.sh name each case "Given ..., when ..., then ...". + - path: ".github/workflows/**" + instructions: | + Keep `permissions` minimal per job, keep `persist-credentials: false` on jobs that + build Graphviz from source so third-party build code never sees the token, verify + every download by checksum, and never merge automatically. The upgrade workflow + opens a PR only; a human merges it. + - path: "{artifacts.sha256,build_*.sh,scripts/bump-graphviz.sh,Containerfile.build,wasm-toolchain.cmake}" + instructions: | + These decide which Graphviz ends up inside every downstream app. A Graphviz + version change must update the pin in all three build scripts consistently and + re-record all three digests in artifacts.sha256. Flag a changed digest without a + matching version or build-script change, and any new unpinned download. + - path: "Package.swift" + instructions: | + Binary target selection runs on the host: `#if os(...)` picks xcframework vs + Linux artifact bundle, and GRAPHVIZ_WASM selects the wasm bundle for cross-builds. + Flag anything that breaks one of the three paths or raises minimum platforms + (macOS 15, iOS 18, Swift tools 6.0) without saying so. + + pre_merge_checks: + docstrings: + mode: "off" # an 80% gate on a small wrapper is noise on every PR + title: + mode: warning + description: + mode: warning + custom_checks: + - name: "Bundled Graphviz consistency" + mode: warning + instructions: | + If the PR changes any of Graphviz.xcframework, CGraphviz.artifactbundle, + CGraphvizWasm.artifactbundle or artifacts.sha256, pass only if all three + libraries are rebuilt from the same Graphviz version, the version pin in + build_linux_static.sh, build_wasm_static.sh and build_xcframework.sh matches it, + and the PR description names that version. Otherwise pass as not applicable. + - name: "Public API break disclosure" + mode: warning + instructions: | + Fail if a public declaration in Sources/SwiftGraphviz is removed or renamed, or a + public signature or default changes, and the PR description does not say so. + Additions do not count. + +knowledge_base: + learnings: + scope: local diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index f871072..0d9073a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,5 +1,5 @@ # Files that run code when the package is resolved or built, the prebuilt libraries -# that end up inside every app and wasm module, and the files that steer coding agents. +# that end up inside every app and wasm module, and the files that steer coding and review agents. # Whoever can change one changes what downstream builds contain, so the maintainer # approves every change. scripts/hygiene.test.sh holds this list to the files that exist. /Package.swift @Vithanco @@ -13,4 +13,5 @@ /CGraphvizWasm.artifactbundle/ @Vithanco /artifacts.sha256 @Vithanco /CLAUDE.md @Vithanco +/.coderabbit.yaml @Vithanco /.github/ @Vithanco diff --git a/scripts/hygiene.test.sh b/scripts/hygiene.test.sh index 57824cb..6c5ef21 100755 --- a/scripts/hygiene.test.sh +++ b/scripts/hygiene.test.sh @@ -38,9 +38,9 @@ done <<< "$patterns" # 14 printf '%s\n' "$patterns" > "$TMP/.git/info/exclude"; bad=0 for path in Package.swift build_xcframework.sh build_linux_static.sh build_wasm_static.sh Containerfile.build \ - Graphviz.xcframework/x CGraphviz.artifactbundle/x CGraphvizWasm.artifactbundle/x CLAUDE.md .github/CODEOWNERS scripts/x.sh; do + Graphviz.xcframework/x CGraphviz.artifactbundle/x CGraphvizWasm.artifactbundle/x CLAUDE.md .coderabbit.yaml .github/CODEOWNERS scripts/x.sh; do echo "$path" | git -C "$TMP" check-ignore --no-index -q --stdin || { fail "not covered by CODEOWNERS: $path"; bad=1; } done -[ $bad -eq 0 ] && pass 'Given CODEOWNERS, when its patterns are read, then it covers the manifest, scripts, binaries, CLAUDE.md and .github/' +[ $bad -eq 0 ] && pass 'Given CODEOWNERS, when its patterns are read, then it covers the manifest, scripts, binaries, agent config and .github/' exit $FAILED From 9dc9c04fd3a61f5f340491c7c565b4341515cd5d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 6 Nov 2026 05:23:33 +0000 Subject: [PATCH 2/2] coderabbit: use auto_approvals.enabled instead of the deprecated request_changes_workflow Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01QehuQ55Dedo7Xa3rY9xRgA --- .coderabbit.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.coderabbit.yaml b/.coderabbit.yaml index cf6547d..e678d17 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -5,7 +5,8 @@ language: en-US reviews: profile: chill - request_changes_workflow: false # single maintainer; checks stay advisory + auto_approvals: + enabled: false # single maintainer; checks stay advisory high_level_summary: true poem: false in_progress_fortune: false