Skip to content

feat(core): ModuleBase.doctor_diagnostics hook; users SM035 origin check - #1152

Merged
antosubash merged 11 commits into
mainfrom
claude/project-thread-lg6bda-doctor
Nov 29, 2026
Merged

antosubash merged 11 commits into
mainfrom
claude/project-thread-lg6bda-doctor

Conversation

@antosubash

@antosubash antosubash commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Requested by Anto · project thread

Summary

Split 3 of 3 from #1137 (after #1150 and #1151, both merged). It's now based on main, with main merged in.

This adds new public API on ModuleBase, so please review it as API, not as part of a bug fix.

  • ModuleBase.doctor_diagnostics(database_url) -> Sequence[Diagnostic]: optional, read-only, Doctor-only (never run at boot), empty by default. Doctor resolves the database URL once and passes it to every hook.
  • SM036 (ERROR, Doctor only): a hook that raises, or returns something that isn't a Diagnostic with a DiagnosticLevel and a string code. Exception text is not printed, because hooks may touch credentials. Doctor continues with the other modules.
  • SM035 (WARNING, Doctor only): the users module's first use of the hook. It fires when users.base_url, host.public_base_url and host.forwarded_host_allowlist are all empty.
  • Docs: .agents/rules/architecture.md (AGENTS.md's lifecycle section moved there on main), docs/framework/lifecycle.md, docs/reference/diagnostic-codes.md, settings docs. CHANGELOG entry under Added.
  • To keep users/module.py under the 300-line cap, its menu URL/icon constants moved to users.core.constants (MENU_URL_*, MENU_ICON_*). Values are unchanged.

New relative to #1137: framework/core/tests/diagnostics/test_module_doctor_hook.py tests the hook at framework level with fake modules: the default is empty, findings are surfaced with the resolved URL, and all four SM036 failure modes report without leaking and let later modules run.

Test plan

  • After merging main: modules/users/tests + framework/core/tests/diagnostics + host/tests: 1923 passed
  • ruff, ty, doc paths, file size, hardcoded strings
  • make ci-doctor shows the expected SM035 and no errors
  • CI green

🤖 Generated with Claude Code

https://claude.ai/code/session_01FXHA3ZEgbUuM5mzoeC4DTw

When neither users.base_url nor host.public_base_url is set, password-reset,
verification and invitation emails link to the current request's origin,
but only if its host matches host.forwarded_host_allowlist (the matcher
ForwardedHostMiddleware uses, applied after proxy handling). Plain http is
accepted only from a trusted proxy or for a loopback host. Otherwise the
mail is still skipped with an ERROR and the public response stays generic.
Sends with no request keep requiring a configured origin.

The shared host parser now uses fullmatch, rejects ports above 65535 and
accepts bracketed IPv6, which ForwardedHostMiddleware also picks up; that
is covered by new middleware tests.

Split out of #1137 (the CIDR fix and the Doctor hook are separate PRs).

Fixes #1126

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXHA3ZEgbUuM5mzoeC4DTw
Modules can add read-only findings to make doctor / smpy doctor through
the new ModuleBase.doctor_diagnostics(database_url) override (never run at
boot). Doctor resolves the database URL once and passes it to every hook.
A hook that raises or returns something other than Diagnostic objects
becomes SM036 (ERROR), without its exception text, and Doctor continues.

The users module uses the hook for SM035: a WARNING when users.base_url,
host.public_base_url and host.forwarded_host_allowlist are all empty, so
account emails have no origin.

Framework-level tests cover the hook without the users module.

Split out of #1137; stacked on the account email origin PR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXHA3ZEgbUuM5mzoeC4DTw
@antosubash antosubash self-assigned this Nov 25, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: a6000dd
Status: ✅  Deploy successful!
Preview URL: https://7f936949.simple-module-python.pages.dev
Branch Preview URL: https://claude-project-thread-lg6bda-aygo.simple-module-python.pages.dev

View logs

…-lg6bda-base-url

# Conflicts:
#	CHANGELOG.md
#	docs/modules/users.md
#	modules/users/users/accounts/manager.py
#	modules/users/users/admin/api.py
#	modules/users/users/admin/views.py
#	modules/users/users/invites/resend.py
…e-url' into claude/project-thread-lg6bda-doctor

# Conflicts:
#	AGENTS.md
#	CHANGELOG.md
@antosubash
antosubash changed the base branch from claude/project-thread-lg6bda-base-url to main November 29, 2026 09:00
antosubash and others added 5 commits November 29, 2026 10:04
…-lg6bda-doctor

# Conflicts:
#	docs/framework/settings.md
#	framework/hosting/simple_module_hosting/pipeline/public_urls.py
#1151 merged as a squash, so the old fallback commit on this branch is
resolved to main's versions. AGENTS.md moved its lifecycle section to
.agents/rules/architecture.md, so the doctor_diagnostics mention moves
there. The users menu URL and icon constants move to users.core.constants
to keep users/module.py under the 300-line cap with the new hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXHA3ZEgbUuM5mzoeC4DTw
The previous merge commit lost its second parent; this records origin/main as a parent without changing files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FXHA3ZEgbUuM5mzoeC4DTw
…tor' into claude/project-thread-lg6bda-doctor
@antosubash
antosubash marked this pull request as ready for review November 29, 2026 09:09
@antosubash antosubash added the shipped /ship passed on the head commit label Nov 29, 2026
@antosubash

Copy link
Copy Markdown
Owner Author

/ship passed on a6000dd

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-29T09:13:39.773116Z a6000dd Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@antosubash
antosubash merged commit ee8e678 into main Nov 29, 2026
22 checks passed
@antosubash
antosubash deleted the claude/project-thread-lg6bda-doctor branch November 29, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

shipped /ship passed on the head commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants