Skip to content

feat(openapi): spec governance M0 — 3-layer reconciliation, P0 schemas, consistency + breaking-change gates - #63

Merged
voidvec merged 7 commits into
masterfrom
feat/openapi-spec-governance-m0
Aug 17, 2026
Merged

voidvec merged 7 commits into
masterfrom
feat/openapi-spec-governance-m0

Conversation

@voidvec

@voidvec voidvec commented Aug 17, 2026

Copy link
Copy Markdown
Owner

A1 — OpenAPI Spec 治理(M0:Layer 1 地基)

设计:docs/productization-evolution/todo/client-sdk-facility-design.md §十(v1.1 M0 修订)
实施计划:docs/productization-evolution/todo/openapi-spec-governance-plan.md(评审 APPROVE-WITH-CHANGES,发现已全部落地)
关键路径:本 PR 是 C1 Python/Go 客户端 SDK 的阻塞项。

问题:三层漂移(2026-08-16 实测)

层 数量 问题
Drogon 路由(真实 API 面) 82 12 条路由从未注册文档、从未入 YAML
C++ 文档注册(指纹基线) 75 5 条幽灵文档(指向不存在的路由)
手维护 YAML 73 8 条死条目 + 缺 13 条真实操作 + info.version 落后两个 minor

典型漂移:YAML 至今还在文档化 3 个月前已删除的 /api/orgs*;MFA 路由迁到 /api/me/mfa/* 后旧路径文档没删、新路径文档没加;/oauth2/logout、/health/ready、RFC 8414 元数据端点从未入档。

交付(6 commits,W1–W8)

  1. d42a61c W2 — C++ 文档注册对账:删 5 处幽灵路径,补 10 处缺注册(end_session/logout/me-mfa/device-approve/health 子探针/RFC 8414),指纹基线 75→80。
  2. 338d7eb W1 — YAML 重写为客户端生成就绪:78 操作与文档注册逐字对账;P0 schema 按控制器实测 wire 契约补齐(TokenRequest 表单体、IntrospectionResponse、OAuth2Error vs ErrorEnvelope 双错误形态、discovery 全字段等);info.version → 1.2.0 联动。
  3. bcfd704 W3 — 治理门:check_spec_governance.py 三层一致性 + 版本同步,fixture 驱动 selftest 覆盖 4 类故障注入。
  4. c5ee505 W4/W5 — CI 接线:ci.yml static-checks 加治理门;新 openapi-governance.yml oasdiff v1.29.1 破坏性变更门(-o ERR);bootstrap 豁免 15 条(每条带理由);release.yml version-check 加 info.version 交叉校验。
  5. 423312a W6 — refactor-baseline 端点签名再生(含 master 存量漂移收敛)。
  6. fe21a52 W8 — 设计文档 v1.1、实施计划、openapi-update skill(4 处镜像)、api-reference、ci-cd-guide、progress 同步。

验收证据

  • ✅ 构建(manage.ps1 build-backend)+ 指纹测试 Integration_P1_OpenApiSpec_Property4_3_1_PathMethodFingerprint_Baseline 绿
  • ✅ 46 个相关测试切片(OpenApiSpec/InitOrder/ApiDoc/Discovery/Health/Mfa/DeviceAuth/OidcBatch)全绿
  • ✅ openapi_spec_validator 绿;治理门 routes=82 docs=80 yaml=78 零差异
  • ✅ 故障注入实测:YAML 删端点 → 门 exit 1 精确指名;源码加路由 → 门 exit 1;oasdiff 删存活路径 → -o ERR exit 1,豁免清单覆盖后 bootstrap diff exit 0
  • ✅ AC8(W7):openapi-python-client 从新 spec 生成客户端,实调活服务器(postgres 模式):
    [1/4] token 200 OK  access_token=7I0e...  expires_in=3600  scope='tokens:read'
    [2/4] introspect 200 OK  active=True  client_id=backend-svc  sub='client:backend-svc'
    [3/4] negative token 401 OK  error='invalid_client' (typed OAuth2Error)
    [4/4] discovery 200 OK  issuer=http://localhost:5555
    
    表单体由生成代码从 schema 构造(无需手拼 form),响应强类型(TokenResponse/IntrospectionResponse/OAuth2Error)。

兼容性说明( reviewers 请看 )

死端点删除与参数位置迁移不改 wire 行为:删除的 8 条端点无路由(调用必然 404);token/introspect/revoke/login 的参数服务器一直同时接受 query 与 form/JSON(Drogon getParameter 语义),spec 只是修正了误导性声明。oasdiff 豁免清单里有逐条理由。

风险与回退

  • 指纹基线更新后无其它测试依赖旧集合(全量 46 切片验证);CI 全量矩阵将二次确认
  • 每个 commit 独立可回滚;YAML 重写只动该动的(P1/P2 端点保留原描述,diff 可审计)

…hs out, missing ops in)

M0 W2 (spec governance):
- MfaController: doc paths /oauth2/mfa/{setup,setup/verify,disable} ->
  /api/me/mfa/{setup,verify,disable} (old paths had no backing routes)
- DeviceAuthController: drop ghost /oauth2/device/verify GET+POST docs
  (verification page is frontend-rendered); add /oauth2/device/approve
- SessionController: add /oauth2/logout, /oauth2/end_session GET+POST,
  /health/live, /health/ready doc registrations
- DiscoveryController: add /.well-known/oauth-authorization-server (RFC 8414)
- Fingerprint test baseline: 75 -> 80 ops, with a header note that the
  governance gate parses it
…of truth

M0 W1 (spec governance):
- endpoint reconciliation: -8 dead entries (/api/orgs*, /oauth2/device/verify,
  old /oauth2/mfa/* paths), +13 missing ops (admin dashboard/organizations/
  scopes-resources, me/mfa/*, device/approve, logout, health/live|ready,
  RFC 8414 metadata) => 78 operations, byte-parity with doc registrations
- P0 schema backfill from controller-verified wire contracts: TokenRequest
  (form body), IntrospectionResponse, UserInfoResponse, OpenIDConfiguration,
  OAuthAuthorizationServerMetadata, JWKSet, OAuth2Error (RFC 6749) vs
  ErrorEnvelope (app envelope incl. numeric_code), TokenResponse with
  per-grant field rules, device/login/MFA/health bodies
- /oauth2/token|introspect|revoke|login|mfa/verify|device_authorization:
  request bodies moved from misleading query params to form/JSON bodies
  (server accepts both; RFC-correct declaration drives client generators)
- info.version 1.0.0 -> 1.2.0 (synced with cmake/Version.cmake, gate-enforced)
…sync

M0 W3: tools/openapi-governance/check_spec_governance.py asserts
- routes (ADD_METHOD_TO scan, multi-line macros, first method token) ==
  doc registrations (kFingerprint parse) modulo ROUTE_ONLY exclusions
- docs == openapi.yaml ops modulo YAML_EXCLUDED self-doc paths
- openapi.yaml info.version == cmake/Version.cmake

Sanity floors (>=60 ops per layer) fail loudly on parse regressions.
Fixture-driven --selftest covers yaml-drop / new-route / ghost-doc /
version-drift fault injections (repo script conventions: 0/1/2 exit codes).
M0 W4/W5:
- ci.yml static-checks: selftest + 3-layer governance check (source-only,
  pyyaml pinned alongside openapi-spec-validator)
- new openapi-governance.yml (PR on spec/tool changes): oasdiff v1.29.1
  pinned binary, base(master) vs PR breaking diff, -o ERR fails the build
- bootstrap errata: 15 exemptions, each with rationale (8 dead-endpoint
  removals, 6 query->form/JSON body relocations, 1 revoke empty-200 fix)
- release.yml version-check: openapi.yaml info.version must match the tag
M0 W6: absorbs both the pre-existing drift on master (69 rows vs 73 YAML ops)
and the M0 schema backfill (statuses/content-types now populated). Verified:
diff mode exits 0 after regen.
…skill update

- client-sdk-facility-design.md v1.1: §十 M0 reconciliation (3-layer drift
  measurements, D1.5 hand-maintained-YAML decision, D3 three-layer gate,
  D4 bootstrap errata + version sync)
- new openapi-spec-governance-plan.md: W1-W7 implementation plan with
  acceptance criteria (reviewed APPROVE-WITH-CHANGES, findings applied)
- openapi-update skill (+ 3 mirrors): governance gate as the authoritative
  validation step, corrected MFA/device endpoint lists, version-sync rules
- api-reference.md: single-source banner + /api/me/mfa path fix
- ci-cd-guide.md: governance gate + oasdiff workflow in the CI map
- next-phase plan / progress-status: A1 delivered
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

…ackstop

Address code-review findings (APPROVE-WITH-CHANGES, 4 MINOR):
- header comment: ignore list is .md, not .yaml
- /oauth2/login 200 success example now matches LoginSuccessResponse and
  the actual handler body ({code, location}); C++ doc example synced
  (CategoryA snapshot doesn't freeze login examples — verified)
- governance gate scans libs/drogon/src/**/*.cc too (closes the
  macro-in-.cc blind spot); fixture now exercises the bare-method-name
  regex branch (PUT /y)
- release.yml version backstop runs the gate script instead of a
  PyYAML-dependent one-liner (no hard dep on runner image packages;
  re-validates 3-layer consistency on the release ref)
@voidvec
voidvec merged commit f581be2 into master Aug 17, 2026
9 checks passed
voidvec added a commit that referenced this pull request Aug 17, 2026
CHANGELOG for v1.2.0 (61 commits since v1.1.0): #43 resource-scope
authorization model, A2 user-management CRUD (PR #52), B1 back-channel
logout backend (PR #50), A1 OpenAPI spec governance M0 + breaking-change
gates (PR #63), benchmark M2-M4 load-bearing verdicts (PR #48), and the
#53-#60 user-admin hardening batch (PR #62).

Per the release SOP (docs/backend/versioning-and-release.md §11.1):
draft via `git cliff --unreleased --tag v1.2.0 --prepend`, then
hand-curated (themed sections, security-hardening migrations, noise
removed). Version SSoT already bumped to 1.2.0 in e5548ec; api-diff and
the new spec-governance gate verified OK on the release ref.
@voidvec
voidvec deleted the feat/openapi-spec-governance-m0 branch August 22, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants