Skip to content

Standardize log levels + broaden local dev/CI config - #17

Merged
voidvec merged 4 commits into
masterfrom
chore/log-level-standardization
Aug 4, 2026
Merged

voidvec merged 4 commits into
masterfrom
chore/log-level-standardization

Conversation

@voidvec

@voidvec voidvec commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Summary

Two related chore commits bundled here for review.

1. chore(logging): standardize log levels across the codebase

Normalizes the six-level logging scheme (trace/debug/info/warn/error/fatal) end to end: port, call sites, config defaults, ctest output, and docs.

Framework

  • Adds LogLevel::Trace to the ILogger port and routes it through DrogonLogger (LOG_TRACE). Previously Trace was absent from the enum and silently dropped by the adapter, yet 39 LOG_TRACE call sites (generated ORM model headers) already existed — the "no LOG_TRACE in scope" premise was stale.
  • Adds FakeLoggerTest.CapturesTraceLevel regression guard.

Call-site audit (~22 misclassified sites, non-generated code only)

  • Recoverable failures that still succeed: error → warn (AuthService role-assign/default-role, PostgresIdentityRepository, MfaController pending-clear, OAuth2CleanupService background failures, ControllerRegistration plugin-not-found fallback).
  • Operations that fail outright with no fallback: warn/debug → error (AuthService validate-user/get-user-info DB exception paths, reset-login-counter write, PostgresTokenRepository introspect-count & revocation-audit writes).
  • DB-exception paths blended into not-found branches: debug → warn (Postgres/Redis grant & token get-or-not-found).
  • Audit-worthy business successes: debug → info (token revocation, consent save/revoke, cleanup-cycle start, RedisRepositoryBase init).

Config defaults

  • config.prod.json: WARN → INFO (per the "production defaults to info+" rule).
  • config.dev.json: revert stray WARN → DEBUG (dev = debug).
  • config.json/config.ci.json already DEBUG, unchanged.

CTest minimal output

  • Drops -V from test.bat and CI (_build-test.yml, _sdk-smoke.yml) so only failed tests print their logs plus the pass/fail/total summary.
  • -q/--quiet now maps to ctest -Q (summary only); --output-on-failure stays the default.

Docs

  • observability.md §3.2: full six-level table, conventions, dynamic log_level adjustment, Domain-via-ILogger / Adapter-via-LOG_* layering rule.
  • testing-guide.md: document the minimal-output ctest strategy.
  • CONTRIBUTING.md: new "Logging" section with quick-decision table + note on deliberately-deferred policy-call sites (audit residue).

2. chore(config): broaden local dev/CI CORS origins and add GitHub OAuth stub

  • cors.allow_origins: drop redundant http://127.0.0.1:5173, add localhost:5174/8080/8081.
  • vue-client.redirect_uri: add http://localhost:8080/callback.
  • external_auth.github: placeholder block (YOUR_GITHUB_CLIENT_ID / YOUR_GITHUB_CLIENT_SECRET) mirroring the existing wechat placeholder — real creds via env-var overrides at runtime.
  • Applies to config.json, config.dev.json, config.ci.json.

Verification

  • Build: windows-msvc preset — clean (C4819 warnings are pre-existing UTF-8/codepage noise, unrelated).
  • Tests: ctest -C Release --output-on-failure → 299/299 passed, 0 failed (incl. the new CapturesTraceLevel regression test).
  • Minimal-output ctest strategy observed end to end (failed-test logs + final summary only).

Notes / out of scope

  • The full migration of ~559 raw LOG_* macro call sites to the ILogger port (design.md §5.6 Task-14) is not included — that's a separate mechanical PR.
  • ~25 "policy-call" log sites (e.g. the [METRIC] log-based metric emissions at info, routine 401/403 denials at warn) are intentionally left for a deliberate follow-up; documented in CONTRIBUTING.md as audit residue.
  • Generated ORM model code (libs/storage-postgres/{src/models,include/.../models}/) correctly uses fatal/trace — untouched.

voidvec added 3 commits August 4, 2026 14:00
1. pre-commit 钩子缺失构建目录守卫 (Medium)
   - .claude/settings.json: 在 cd build/tests 前添加目录存在性检查
   - 缺失时输出构建引导而非误导性的 'Tests failed'

2. MCP 配置明文凭据已被版本控制跟踪 (Medium)
   - 将 .mcp.json 从 git 跟踪中移除,加入 .gitignore
   - 新建 .mcp.json.example 使用环境变量引用

3. 迁移 Skill 引用过时版本号 (Low)
   - .claude/skills/create-migration/SKILL.md: 移除硬编码 V018 版本号
   - 改为动态 ls 检查命令,从根本上消除版本号漂移
Normalize the six-level logging scheme (trace/debug/info/warn/error/fatal)
end to end: port, call sites, config defaults, ctest output, and docs.

Framework:
- Add LogLevel::Trace to the ILogger port (ILogger.h) and route it through
  DrogonLogger (LOG_TRACE). Previously Trace was absent from the enum and
  silently dropped by the adapter, yet 39 LOG_TRACE call sites (generated
  ORM model headers) already existed -- the "no LOG_TRACE in scope" premise
  was stale. Add a FakeLoggerTest.CapturesTraceLevel regression guard.

Call-site audit (~22 misclassified sites, non-generated code only):
- Recoverable failures that still succeed: error -> warn
  (AuthService role-assign/default-role, PostgresIdentityRepository same,
  MfaController pending-clear, OAuth2CleanupService background failures,
  ControllerRegistration plugin-not-found fallback).
- Operations that fail outright with no fallback: warn/debug -> error
  (AuthService validate-user/get-user-info DB exception paths, reset-login-
  counter write, PostgresTokenRepository introspect-count & revocation-audit
  writes).
- DB-exception paths blended into not-found branches: debug -> warn
  (Postgres/Redis grant & token get-or-not-found).
- Audit-worthy business successes: debug -> info (token revocation, consent
  save/revoke, cleanup-cycle start, RedisRepositoryBase init).

Config defaults:
- config.prod.json: WARN -> INFO (per the "production defaults to info+" rule).
- config.dev.json: revert the stray WARN back to DEBUG (dev = debug).
  config.json/config.ci.json already DEBUG, unchanged.

CTest minimal output:
- Drop -V from test.bat and CI (_build-test.yml, _sdk-smoke.yml) so only
  failed tests print their logs plus the pass/fail/total summary.
- -q/--quiet now maps to ctest -Q (summary only); --output-on-failure stays
  the default. test.sh was already minimal.

Docs:
- observability.md §3.2: full six-level table, conventions, dynamic
  log_level adjustment, and the Domain-via-ILogger / Adapter-via-LOG_*
  layering rule.
- testing-guide.md: document the minimal-output ctest strategy.
- CONTRIBUTING.md: new "Logging" section with a quick-decision table and
  a note on the deliberately-deferred policy-call sites (audit residue).

Verified: windows-msvc build clean; ctest -C Release --output-on-failure
=> 299/299 passed, 0 failed (incl. the new Trace regression test).
… stub

Align the local-development and CI runtime configs with the ports the
frontends/tooling actually use, and stub out the GitHub external-auth
provider mirroring the existing wechat placeholder.

- cors.allow_origins: drop the redundant http://127.0.0.1:5173 (the
  localhost form already covers it) and add localhost:5174/8080/8081 so
  the alternate Vite dev port and the backend/swagger ports are accepted.
- vue-client.redirect_uri: also accept http://localhost:8080/callback
  alongside the 5173 callback.
- external_auth.github: add a placeholder block (YOUR_GITHUB_CLIENT_ID /
  YOUR_GITHUB_CLIENT_SECRET) matching the existing wechat placeholder
  pattern; real credentials are supplied via env-var overrides at runtime.

Applies to config.json, config.dev.json, and config.ci.json.
@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.

The LogLevel::Trace addition in ILogger.h is a public SDK header change
(under include/authforge/**), so the api-diff guard flags it as additive
drift on CI. Per the tool's own guidance (and CONTRIBUTING.md), additive
changes are ratified by regenerating the baseline -- no version bump is
required for pure additions.

Regenerated via: python tools/api-diff/api_diff.py --update-baseline
Verified: the only delta is the single "Trace," enum line; the guard now
reports "OK (164 headers match baseline)".
@voidvec
voidvec merged commit f500f57 into master Aug 4, 2026
8 checks passed
@voidvec
voidvec deleted the chore/log-level-standardization branch August 9, 2026 11:49
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