Skip to content

ci: run Gaze on reading-stone with reading-stone as the TypeScript analyzer #40

Done

Description

@jflowers

Goal

Run Gaze on reading-stone in CI, with reading-stone as Gaze's TypeScript analyzer. Every PR then gets a Gaze quality report on the code it changes, analyzed by the analyzer built from that PR.

What gaze init gives us (nothing to do)

Gaze v2.5.0 gaze init is already applied here. gaze init --force changes no file:

  • Agents: .opencode/agents/divisor-gaze-testing.md, gaze-reporter.md and gaze-test-generator.md are present.
  • Commands: /gaze, /gaze-fix and /speckit.testreview are present.
  • Review council: divisor-gaze-testing is registered in .uf/review-matrix.yaml and .uf/reviewer-capabilities.yaml.

gaze init --ci does not write the CI workflow for this repository:

Warning: skipping CI scaffolding (--ci): the reusable gaze AI-report workflow analyzes ./... from the repository root and requires a Go module there.

Gaze's reusable workflow (reusable_gaze_ai_report.yml) is Go-only:

  • it installs Go and takes a Go coverprofile;
  • it runs gaze report ./... --ai=opencode with no --analyzer.

So reading-stone needs its own job until Gaze's workflow supports external analyzers.

Local proof (Gaze v2.5.0, main at c646a8d)

npm ci && npm run build
npx vitest run --coverage            # writes coverage/coverage-final.json (v8 default json reporter)
chmod +x dist/main.js                # tsc output has the shebang but not the exec bit
ln -s "$PWD/dist/main.js" <dir-on-PATH>/gaze-analyzer-typescript
gaze report ./src/... --analyzer gaze-analyzer-typescript --format=json
  • Runtime: about 17 seconds.
  • Sections: CRAP, quality, classification and docs all filled in, with no errors.

Results for src/ only:

Metric Value
Functions 360
Avg line coverage 94.8%
CRAPload (≥15) 9 (2.5%, A-)
GazeCRAPload (≥15) 165 (45.8%, F)
Tests mapped 834
Avg contract coverage (quality) 45.9%

Gotchas found

  1. Scope to ./src/.... With the default ./..., reading-stone's discovery walks .opencode/; only node_modules, dist, build, coverage and .git are pruned. That adds 645 scaffolded plugin functions, and the numbers sink: 1005 functions at 34% average coverage, CRAPload 280.
  2. --language typescript alone fails with no go.mod found; that's gaze report: honor --language alone for external analyzer dispatch unbound-force/gaze#282. Pass --analyzer explicitly until that's fixed.
  3. dist/main.js isn't executable after tsc. Gaze spawns the analyzer binary directly, so it needs chmod +x. The other option is to put it on PATH with npm link or npm install -g ..

Proposed work

Make it an OpenSpec change, because it's a CI change: spec commit first, then the implementation.

  1. Add a gaze job. Either add it to ci.yml or make a separate gaze.yml; decide in the design. The job:
    • checks out the code, sets up Node 24, and runs npm ci and npm run build;
    • runs npx vitest run --coverage, or reuses the test (24) job's coverage as an artifact;
    • sets up Go and runs go install github.com/unbound-force/gaze/v2/cmd/[email protected], pinned to the version;
    • exposes dist/main.js as gaze-analyzer-typescript on PATH;
    • runs gaze report ./src/... --analyzer gaze-analyzer-typescript --format=markdown, writes the result to $GITHUB_STEP_SUMMARY, and uploads the JSON or HTML report as an artifact.
  2. Start report-only, with no thresholds. Decide the gates separately; they're governance values, so a maintainer sets them. A baseline from the numbers above:
    • --max-crapload around 9–10;
    • GazeCRAPload and contract coverage are too low to gate yet.
  3. Permissions: contents: read only. No secrets, and no AI adapter (--ai) for now.
  4. Required check: add the job's check name to ci_checks in release.yml only if it becomes required.

Out of scope / follow-ups

  • AI-written report (--ai=opencode) through Gaze's reusable workflow. That needs Gaze upstream to:

    • make reusable_gaze_ai_report.yml accept an external analyzer and non-Go coverage;
    • make gaze init --ci scaffold it for non-Go repos.

    It needs its own issue on unbound-force/gaze.

  • Discovery excludes. Reading-stone could prune .opencode/, or honor .gitignore or a .gaze.yaml exclude list, so the default ./... gives sensible numbers. That's a separate reading-stone change (discovery spec FR-003).

Constitution notes

  • Analysis safety (V): the analyzer reads the repository's own source statically. Nothing analyzed is executed beyond the repository's existing test run.
  • Testability (IV): the job dogfoods the analyzer built from the PR, so a bad analyzer change fails or skews its own report.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions