Consumer Guide · Gate Rules · Trust Model · Auth · Templates · Discussions
square² (方方) is a zero-dependency, repo-agnostic governance skeleton (Node ≥ 22, MIT) built around two non-blocking planes: a deterministic ratcheting quality gate that fails only on new regressions with concrete Instead: fixes, and an advisory cross-family AI code review where a different model family audits commits in a credential-isolated read-only copy.
npm install
npm run typecheck
npm testDrop-in consumer workflows, .square2/ configs, and pre-push hooks live in templates/consumer/.
Run from your repo root (or pass --root <dir>). Exit codes: 0 pass · 1 violations · 2 tool/config/vendor error.
| Command | Purpose |
|---|---|
square2 check [--only <ids>] [--format text|github] [--report <path>] [--base <sha>] [--rev <sha>] |
Self-test enabled rules, subtract .square2/baseline.json + live exceptions, print [ID] path:line — Instead: …. Enforces baseline ratchet & exception immutability with --base. |
square2 selftest [--only <ids>] |
Verify every enabled rule fires on .square2/fixtures/<id>/bad/ and stays silent on good/. |
square2 baseline show | shrink | grow --approval <id> |
Inspect, shrink resolved entries, or grow baseline citing .square2/approvals.yaml. |
square2 exceptions lint [--base <sha>] |
Validate .square2/exceptions.yaml TTLs and immutability. |
square2 vendor --from <path|git-url> --ref <tag> [--into <dir>] |
Copy square² into tools/square2/ and pin tree_sha256 in .square2/lock.json. |
square2 replay --rule <id> (--commit <sha> | --since <days>) [--out <file>] |
Replay a candidate rule on git history in a temporary worktree before enabling it. |
square2 review prepare | run | validate | publish | guard-env |
3-stage daily cross-family review (prepare → read-only run with no GH token → validate/publish). |
square2 publish-gate [--report <path>] [--branch <name>] [--test] |
Open GitHub issues for new gate violations on the configured branch. |
square2 budget |
Track month-to-date Actions minutes against your threshold. |
square2 config get <key> |
Print a scalar from .square2/config.yaml. |
Configuration (.square2/config.yaml) & Pluggable Engines
approvers: - some-login max_exception_ttl_days: 90 require_provenance: false # true: every enabled rule needs born_from + replay report generated: - apps/web/generated/** engines: ruff: command: [uv, run, --project, python, ruff] depcruise: config: .dependency-cruiser.cjs eslint: config: eslint.config.mjs escapes: enabled: false # experimental escape records (default false) review: author_trailers: # trailers naming the writers (default Co-Authored-By) - Co-Authored-By - X-Writers change_id_trailers: # trailers whose value is a change id (default none) - X-Change provenance_trailers: # further trailers shown on escape records (default none) - X-Reviewers
Escape records (experimental, off by default; escapes.enabled: true): fix commits on the reviewed branch become square2:escape issues (one per fix sha, no model call); a fix that closes a gate or review issue credits that issue instead. See docs/consumer-guide.md.
Engines: depcruise and eslint run the repository's own installed tools; ruff runs the configured command; suppressions is built in; command runs options.argv (with {root} replaced by the tree to scan) and reads one JSON object per line: {"path": "src/a.ts", "line": 3, "subject": "what is wrong"}.
- 0.1.2:
SQ2_LLM_BASE_URLroutes the analysis through an OpenAI-compatible Responses gateway (https, or http on loopback only); provider request and stream retries (SQ2_LLM_RETRIES, default 20) and a 10-minute stream idle timeout for throttled deployments; the analyze job can run on a self-hosted runner (SQ2_ANALYZE_RUNS_ON). The escape-record redesign moves to 0.1.3. - 0.1.1: configurable author, change-id and provenance trailers (
review.*_trailers); commit trailers outside that allow-list never reach the review context or prompts; the model override (SQ2_REVIEW_MODEL) applies only within the selected reviewer's family; the pre-push hook skips checkouts withouttools/square2; escape records added as an experimental feature, off by default (escapes.enabled), to be redesigned in 0.1.2. - 0.1.0: first release.
Tamper-Evident Vendoring & CI Agnosticism
- Vendoring:
square2 vendorpinstree_sha256in.square2/lock.json. Any unexpected modification exits2with[S2-VENDOR-TAMPERED]. Threat model: detects accidental edits of the vendored copy; a committer can always change policy, which review of the commit must catch. - CI Agnosticism:
.github/workflows/ci.ymlrunstypecheck,test, and an optional agnosticism grep usingSQ2_FORBIDDEN_PATTERN(skipped on forks) so the public skeleton never leaks consumer names.
FAQ
- Does square² block PR merges? Both planes are advisory by default (
v0.1): square² reports violations and opens issues without blocking merges. - Why split AI review into 3 steps? Keeping
review runstrictly read-only with zero GitHub token ensures an untrusted model call cannot mutate repository state or exfiltrate write credentials. - Why zero runtime dependencies? Vendoring square² into
tools/square2/stays fast, auditable, and immune to supply-chain churn.
Licensed under MIT (LICENSE). See CONTRIBUTING.md to contribute.