Skip to content

Address architecture review findings: slog logging, /metrics endpoint, dashboard hook, e2e journeys, dependency upgrades - #80

Merged
evenluo merged 8 commits into
mainfrom
refactor/architecture-review-followups
Aug 5, 2026
Merged

Address architecture review findings: slog logging, /metrics endpoint, dashboard hook, e2e journeys, dependency upgrades#80
evenluo merged 8 commits into
mainfrom
refactor/architecture-review-followups

Conversation

@evenluo

@evenluo evenluo commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses the findings from the architecture review of the previous PR (#78) and the follow-up code-review loop. Seven coherent commits:

  1. refactor(logging): migrate all remaining logrus call sites to log/slog (13 files, incl. app/poller/repository/service/cpa), unify gin bridge and level mapping (trace→debug, fatal/panic→error)
  2. feat(api): new public GET /metrics runtime snapshot — uptime, poller state, rollup backfill status, last backup time, redis_inbox_pending backlog, and Redis inbox processing throughput counters + derived rate per minute (failed/empty batches excluded); DB read failures degrade to db_unavailable: true instead of failing the endpoint
  3. chore(deps): Go toolchain 1.22 → 1.25, x/crypto 0.23→0.54, x/net 0.25→0.57, x/sys, x/text, x/arch refreshed; logrus removed
  4. refactor(web): index.lazy.tsx 562 → 101 lines; page state/queries/view-model extraction into useUsageDashboard hook; presentation components moved to components/intelligence; DOM/aria-labels unchanged (covered by e2e)
  5. test(e2e): 4 core-journey specs (login redirect → dashboard render → range/granularity switch driving API params & KPIs → provider filter + manual sync) backed by a shared mock-api.ts; mobile spec reuses the shared mocks
  6. docs(adr): ADR-0006 time-zone contract (UTC storage / localtime day aggregation / UTC hour buckets), ADR-0007 public metrics endpoint decision
  7. chore: ignore playwright test artifacts

Verification

  • make verify-backend: go build + 17 packages tests + go vet — all green
  • make verify-frontend: eslint + 114 vitest tests + typecheck + build — all green
  • 24 Playwright e2e (mobile/tablet/desktop × 8) — all green
  • make verify-docker (golang:1.25-alpine, CGO SQLite) — build success
  • Manual smoke: /healthz, /metrics, embedded frontend HTML all served correctly

Compatibility

  • Logging output format changes from logrus text to slog text (both include timestamps; field names preserved). Only externally observable change.
  • /metrics is a new public endpoint (same visibility as /healthz), documented in ADR-0007; reverse proxy can enforce auth for deployments that need it.
  • No API contract, SQLite schema, ingestion, auth, or deployment changes.

Auto-close: none

@cursor

cursor Bot commented Aug 5, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b27cdc7e63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/app/backup_runner.go Outdated
}
r.mu.Lock()
defer r.mu.Unlock()
return r.lastBackupAt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include persisted backup history in metrics

在服务重启后但下一次备份尚未执行前,备份目录中已经存在的备份会被 lastBackupAtFromHistory() 用来安排下一次备份,但新暴露的 /metrics 只通过 LastBackupAt() 读取进程内的 lastBackupAt。因此这段代码会返回零值,导致 last_backup_at 从指标中消失,监控会误判当前部署从未成功备份;建议这里也读取已有的 history 结果或复用相同的历史合并逻辑。

Useful? React with 👍 / 👎.

Address Codex review P2: /metrics last_backup_at read only the
in-memory lastBackupAt, so after a service restart it returned the
zero value until the next backup ran, making monitoring report that
no backup ever succeeded. LastBackupAt now reuses the same
history-merge logic as the scheduling path.
@evenluo

evenluo commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

Addressed the Codex review feedback:

Fixed: P2 — include persisted backup history in /metrics last_backup_at

  • internal/app/backup_runner.goDatabaseBackupRunner.LastBackupAt() now reuses the same lastBackupAtFromHistory() merge logic as the scheduling path, so after a service restart the metric reports the latest backup persisted on disk instead of the zero value.
  • Added two tests: restart-with-persisted-history fallback and in-memory-newer preference.

Verification: go test ./internal/app/ (all pass, incl. 2 new tests), go vet ./internal/app/ clean.

Commit: 3f83c30

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 3f83c307a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@evenluo
evenluo merged commit 5db90d6 into main Aug 5, 2026
1 check passed
@evenluo
evenluo deleted the refactor/architecture-review-followups branch August 5, 2026 07:35
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.

1 participant