Skip to content

build: first-party warning governance (W4 / Wall+Wextra) with CI WERROR gate - #14

Merged
voidvec merged 8 commits into
masterfrom
build/warning-governance
Jul 31, 2026
Merged

voidvec merged 8 commits into
masterfrom
build/warning-governance

Conversation

@voidvec

@voidvec voidvec commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary / 摘要

Batch 5 of the professionalization plan: first-party compiler warning governance with a CI warnings-as-errors gate.

专业化计划批次5:一方代码编译警告治理 + CI 警告即错误门禁。

Changes / 变更

New: cmake/Warnings.cmake

  • oauth2_apply_warnings(target) following the existing oauth2_apply_compat function pattern
  • MSVC: /W4 + /external:anglebrackets /external:W0 (isolates Conan third-party headers)
  • GCC/Clang: -Wall -Wextra (third-party headers already exempt via SYSTEM includes)
  • AUTHFORGE_WERROR option (default OFF) escalates to /WX / -Werror
  • All flags PRIVATE — nothing leaks into the install(EXPORT) interface of the 8 SDK packages

Applied to 10 first-party targets

8 SDK libs (common, common-testing, oauth2, identity, storage-postgres, storage-memory, storage-redis, drogon) + authforge-server + authforge-tests, each behind the same standalone-build guard used for Compatibility.cmake.

ORM model exemption

drogon_ctl-generated models (libs/storage-postgres/src/models/*.cc, must not be hand-edited) get a source-file-level /wd4100 / -Wno-unused-parameter. Hand-written sources keep full warning level.

CI gate

-DAUTHFORGE_WERROR=ON injected via configure_extra_args on all three platform workflows. Local developer builds (README Quick Start presets) are unaffected — default stays OFF.

Warning fixes (zero new warnings under /W4 + /WX)

~24 fixes across storage/drogon/test layers: unused parameters commented out per project convention (const T & /*name/), dead locals removed, (void)TEST_CTX; added to assert-free DROGON_TESTs.

Verification / 验证

  • Local: cmake --preset windows-msvc -DAUTHFORGE_WERROR=ON + full build → BUILD_EXIT=0, zero warnings (4 iterative build rounds to surface and clear all layers)
  • CI on this PR exercises the gate on Linux GCC / macOS Clang / Windows MSVC — -Wextra may surface platform-specific findings not visible to MSVC; will fix in follow-up commits on this branch if any appear

…gate

- Add cmake/Warnings.cmake with oauth2_apply_warnings(): MSVC /W4 with
  /external:anglebrackets /external:W0, GCC/Clang -Wall -Wextra; the
  AUTHFORGE_WERROR option (default OFF) escalates to /WX or -Werror
- Apply to all 10 first-party targets (8 SDK libs, server, tests) as
  PRIVATE flags so nothing leaks into the install(EXPORT) interface
- Exempt drogon_ctl-generated ORM models (storage-postgres src/models)
  from unused-parameter warnings at the source-file level
- Enable -DAUTHFORGE_WERROR=ON in CI on all three platforms via
  configure_extra_args; local developer builds keep the default OFF
- Fix all newly surfaced warnings (C4100/C4189) across storage, drogon
  and test layers: comment out unused parameter names per project
  convention, drop dead locals, reference TEST_CTX in assert-free tests

Verified locally: cmake --preset windows-msvc -DAUTHFORGE_WERROR=ON
builds the full tree with zero warnings (BUILD_EXIT=0).
@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.

voidvec added 7 commits July 31, 2026 15:24
- ISubjectMappingRepository.h: comment out unused parameter names in the
  default createUserForExternalLogin implementation (GCC
  -Werror=unused-parameter fires on inline header definitions)
- storage-postgres: extend the ORM model source-level exemption with
  -Wno-deprecated-declarations (AppleClang flags the generated
  std::codecvt usage in AuditLogs.cc)

Windows MSVC re-verified locally: BUILD_EXIT=0.
Commenting out the parameter names in the createUserForExternalLogin
declaration tripped the api-diff gate (text-level baseline compare treats
it as a breaking declaration change). Keep the declaration lines
byte-identical to the baseline and consume the parameters inside the
default body instead.

Verified: python tools/api-diff/api_diff.py -> OK; MSVC WERROR build
BUILD_EXIT=0.
- PostgresIdentityRepository: drop two unused lambda captures of userId
  (AppleClang -Wunused-lambda-capture)
- Warnings.cmake: add -Wno-missing-field-initializers on GCC/Clang;
  -Wextra flags partial aggregate init (OpenAPI descriptor structs) but
  the remaining members are value-initialized per the standard, so this
  warning subset is noise rather than a defect signal

Windows MSVC re-verified locally: BUILD_EXIT=0.
- Property4_RbacDecisionBaselineTest: iterate the path list as const
  char* instead of binding const std::string& to a per-iteration
  temporary (GCC -Werror=range-loop-construct)
- PostgresTokenRepository: drop unused 'this' lambda capture; the lambda
  already holds the instance alive via self = shared_from_this()
  (AppleClang -Wunused-lambda-capture)

Windows MSVC re-verified locally: BUILD_EXIT=0.
…apture noise

- AuthService: drop unused userId capture in the role-lookup lambda
- FunctionalTest/SecurityTest: consume rateLimitDetected via (void) cast
  (GCC -Werror=unused-but-set-variable; the rate-limit probes verify the
  mechanism exists without asserting on the outcome)
- Warnings.cmake: disable -Wunused-lambda-capture on Clang; a heuristic
  scan found ~50 sites where async Drogon callback chains over-capture
  for lifetime clarity - Clang-only diagnostic, zero behavioural impact,
  and per-site removal risks breaking captures used by nested lambdas

Windows MSVC re-verified locally: BUILD_EXIT=0.
AppleClang rejects plain lambda capture of structured bindings under
-Werror,-Wc++20-extensions (a C++20 feature; the project targets C++17).
Switch the two IdentityService lambdas to init-captures (sub = sub etc.),
which are valid C++17 and copy the same values. Scanned the rest of the
tree: no other structured binding is captured by a lambda.

Windows MSVC re-verified locally: BUILD_EXIT=0.
…eams

trantor's LogStream has no operator<< overload for iostream manipulators,
so 'LOG_X << std::hex << kSeed << std::dec' converted the function
addresses to bool and printed '1' instead of the hex seed (AppleClang
-Wpointer-bool-conversion, 67 sites across the four error property test
files). Pre-format the seed via a per-file ostringstream seedHex() helper
so failure logs now actually show the reproducible seed value.
@voidvec
voidvec merged commit 186f651 into master Jul 31, 2026
8 checks passed
@voidvec
voidvec deleted the build/warning-governance branch July 31, 2026 10:14
voidvec added a commit that referenced this pull request Aug 30, 2026
…loor, bootstrap self-heal, review cleanups

Address PR #141 review (1 must-fix, 8 should-fix, quick considers):

- #1 consent_csrf declared as a required query parameter in openapi.yaml
  and the C++ endpoint doc registration; apps/server/docs/api/openapi.json
  regenerated from a live server run; Python/Go clients regenerated.
- #2 nonce one-shot is now atomic: the find/verify/erase sequence is
  serialized by a process-wide mutex (consent traffic is tiny; in-process
  session storage).
- #3 identity AuthService no longer captures this in the async validateUser
  callback — the legacy-hash policy flag is value-captured
  (db-operations rule 4).
- #4/#12 AdminBootstrapper reworked as ensure-* steps: an existing admin
  user row is reused and role/mapping completed (partial failures self-heal
  on restart); the random password is printed only after the insert
  succeeded; a mapping failure no longer reports created=true.
- #5 POST /api/admin/users enforces auth.min_password_length
  (VALIDATION_PASSWORD_TOO_SHORT) — closing the admin bypass.
- #6 consent integration tests reworked: missing-nonce now drives the real
  authorize-minted slot (400), deny-to-unregistered-uri (400, no Location)
  and deny-to-registered-uri (302 access_denied) branches are covered.
- #7/#8 deployment.md: auto-bootstrap wording fixed, bogus ADMIN_SALT
  removed (PBKDF2 keeps salt empty); website i18n error table mirrored
  (3014/4007).
- #9 main.cc bootstrap probes with backoff (5 attempts) and LOG_WARN on
  failure instead of a single silent 2s probe.
- #13 unique-violation detection layered (SqlError 23505 -> constraint
  name -> english/zh localized text), mirroring the
  PostgresSocialAccountRepository pattern.
- #11 gate-4 comment corrected; #15 CHANGELOG duplicate Unreleased merged;
  #17 AGENTS.md consent.csp entry removed.

Considered-but-not-taken: #10 multi-slot nonces (tracked follow-up), #14
admin UI hardcode (server now enforces; hint stays), #18 MFA-pending
session through consent (pre-existing authorize behavior, tracked).
voidvec added a commit that referenced this pull request Aug 30, 2026
…loor, bootstrap self-heal, review cleanups

Address PR #141 review (1 must-fix, 8 should-fix, quick considers):

- #1 consent_csrf declared as a required query parameter in openapi.yaml
  and the C++ endpoint doc registration; apps/server/docs/api/openapi.json
  regenerated from a live server run; Python/Go clients regenerated.
- #2 nonce one-shot is now atomic: the find/verify/erase sequence is
  serialized by a process-wide mutex (consent traffic is tiny; in-process
  session storage).
- #3 identity AuthService no longer captures this in the async validateUser
  callback — the legacy-hash policy flag is value-captured
  (db-operations rule 4).
- #4/#12 AdminBootstrapper reworked as ensure-* steps: an existing admin
  user row is reused and role/mapping completed (partial failures self-heal
  on restart); the random password is printed only after the insert
  succeeded; a mapping failure no longer reports created=true.
- #5 POST /api/admin/users enforces auth.min_password_length
  (VALIDATION_PASSWORD_TOO_SHORT) — closing the admin bypass.
- #6 consent integration tests reworked: missing-nonce now drives the real
  authorize-minted slot (400), deny-to-unregistered-uri (400, no Location)
  and deny-to-registered-uri (302 access_denied) branches are covered.
- #7/#8 deployment.md: auto-bootstrap wording fixed, bogus ADMIN_SALT
  removed (PBKDF2 keeps salt empty); website i18n error table mirrored
  (3014/4007).
- #9 main.cc bootstrap probes with backoff (5 attempts) and LOG_WARN on
  failure instead of a single silent 2s probe.
- #13 unique-violation detection layered (SqlError 23505 -> constraint
  name -> english/zh localized text), mirroring the
  PostgresSocialAccountRepository pattern.
- #11 gate-4 comment corrected; #15 CHANGELOG duplicate Unreleased merged;
  #17 AGENTS.md consent.csp entry removed.

Considered-but-not-taken: #10 multi-slot nonces (tracked follow-up), #14
admin UI hardcode (server now enforces; hint stays), #18 MFA-pending
session through consent (pre-existing authorize behavior, tracked).
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