Skip to content

Refactor: align codebase with engineering standards #97

@rianjs

Description

@rianjs

Summary

Align the gro codebase with engineering standards for consistency, mechanical enforcement, and maintainability. This is a multi-commit refactoring effort covering architecture enforcement, test infrastructure, documentation, and bug fixes.

Changes

Architecture & Enforcement

  • Add structural tests (internal/architecture/architecture_test.go) that mechanically enforce codebase patterns at CI time: client interfaces, ClientFactory DI, NewCommand() factories, --json on leaf commands, read-only scopes, dependency direction
  • Add coverage gate to CI (60% threshold)

Code Standards Alignment

  • Propagate context.Context through all API client methods and command handlers
  • Relocate interfaces from implementation packages to consumer packages (interface-at-consumer pattern)
  • Remove deprecated gmail wrapper functions
  • Use present participle in error messages per Go conventions
  • Add signal handling with context propagation

Test Infrastructure

  • Remove testify dependency, replace with stdlib-based assertion helpers (internal/testutil/assert.go)
  • Centralize CaptureStdout and generic WithFactory[T] helpers (internal/testutil/helpers.go)
  • Add t.Parallel() to safe test files
  • Add function-field mock structs with compile-time interface checks in each domain

Documentation

  • Restructure CLAUDE.md as a concise table of contents (~90 lines, down from ~350)
  • Create docs/architecture.md, docs/golden-principles.md, docs/adding-a-domain.md
  • Add package doc comments to all packages

Bug Fixes

  • Fix --json flag ignored on empty results across all list/search commands (output [] instead of plaintext)

Build & Lint

  • Align Makefile targets and CI workflow
  • Clean up stale lint suppressions in .golangci.yml

Verification

  • make check passes (tidy, lint, test, build)
  • make test-cover-check passes (63.6% coverage, 60% threshold)
  • All 12 structural tests pass
  • Integration tests pass against live Google APIs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions