feat(proto): add agent.proto contract + buf toolchain (tsk_V9IrIk2g5Q78)

Introduces the frozen control-plane ↔ agent gRPC contract and the full
buf v2 code-generation pipeline that task #6/#14/#15 depend on.

Changes:
- server/proto/pangolin/agent/v1/agent.proto: AgentService with 6 RPCs
  (Enroll, Register, Heartbeat, Subscribe, Ack, ReportUsage) and all
  supporting message types (Command + 5 payload variants, ConfigSnapshot,
  CredentialEntry, NodeLoad, UsageItem).  Red-line comments prohibit
  user_id/email and destination-address fields per privacy policy.
- server/buf.yaml: v2 format, STANDARD lint + FILE breaking rules.
- server/buf.gen.yaml: remote protoc-gen-go v1.36.4 + protoc-gen-go-grpc
  v1.5.1 plugins, out=internal/pb, paths=source_relative.
- server/internal/pb/pangolin/agent/v1/: generated agent.pb.go +
  agent_grpc.pb.go committed to repo (CI diff-clean verified).
- server/Makefile: proto / proto-lint / proto-breaking targets added.
- server/tools.go: buf v1.70.0, protoc-gen-go, protoc-gen-go-grpc pinned.
- server/go.mod / go.sum: buf and grpc tool deps added via go mod tidy.

Acceptance verified:
  buf lint  → zero warnings
  buf generate × 2 → git diff clean (idempotent)
  go build ./... → passes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-13 12:13:43 +08:00
parent 787151245e
commit 6e2657049e
9 changed files with 2406 additions and 70 deletions
+13 -1
View File
@@ -1,4 +1,4 @@
.PHONY: build test test-unit test-integration vet lint generate migrate-up migrate-down build-codegen deps
.PHONY: build test test-unit test-integration vet lint generate migrate-up migrate-down build-codegen deps proto proto-lint proto-breaking
# ── deps ───────────────────────────────────────────────────────────────────────
deps:
@@ -32,6 +32,18 @@ lint:
generate:
@echo "generate: not yet configured (see task 1d)"
# ── proto ──────────────────────────────────────────────────────────────────────
proto: ## 从 proto/ 生成 internal/pb/ 代码(buf generate
go run github.com/bufbuild/buf/cmd/buf@v1.70.0 generate
proto-lint: ## 检查 proto 语法与命名规范(buf lint
go run github.com/bufbuild/buf/cmd/buf@v1.70.0 lint
proto-breaking: ## 与 main 分支对比检测 breaking changebuf breaking
## 注:proto 首次合入 main 前,main 无 .proto 文件,此命令预期报"had no .proto files"
## proto 合入 main 后,后续所有变更须通过此检查,无报错视为通过。
go run github.com/bufbuild/buf/cmd/buf@v1.70.0 breaking --against '../.git#branch=main,subdir=server'
# ── migrate ────────────────────────────────────────────────────────────────────
migrate-up:
@echo "migrate-up: see cmd/migrate"