Skip to content

refactor: codebase cleanup + offline-safe geoip feature split#26

Merged
isala404 merged 6 commits into
mainfrom
codebase-cleanup-optimization
Jun 5, 2026
Merged

refactor: codebase cleanup + offline-safe geoip feature split#26
isala404 merged 6 commits into
mainfrom
codebase-cleanup-optimization

Conversation

@isala404
Copy link
Copy Markdown
Owner

@isala404 isala404 commented Jun 5, 2026

What changed

A codebase cleanup pass plus one user-facing change to how GeoIP is built.

GeoIP feature split (breaking)

geoip is now offline-safe: it pulls only the pure-Rust maxminddb MMDB reader and is included in the default full preset, so cargo build works in air-gapped/CI environments. The bundled DB-IP Country Lite database (and its build-time network download) moved to a new opt-in geoip-embedded feature.

Breaking: zero-config country enrichment now requires --features geoip-embedded. The default build enriches country/city only when signals.geoip_db_path points at a GeoLite2-City MMDB. The GeoIpResolver backend is now gated across three feature combinations (neither / geoip / geoip-embedded); match arms are exhaustive for each.

Internal refactors (no public API change)

  • forge-macros: consolidated duplicated attribute parsing into attrs.rs, used by the query/mutation/job/cron/workflow/daemon/mcp_tool macros.
  • forge-core: declarative macros generate the sealed handler-context impls and the eight test-context builder setters that were previously hand-duplicated.
  • @forge-rs/svelte: extracted a shared StoreCore pub-sub core; the connection/query/subscription/workflow/optimistic stores now build on it, with the last-unsubscribe cleanup hook preserved.
  • forge CLI: Forge::run() no longer mutates its config in place; telemetry/migration init extracted.

Verified

  • cargo fmt --all --check
  • cargo clippy --all-targets --all-features --workspace -- -D warnings
  • cargo test --workspace (SQLX_OFFLINE=true)

Docs updated alongside code: docs/docs/scale/binary-size.mdx, docs/docs/ship/signals.mdx, and the skill references (api.md, frontend.md). CHANGELOG updated under [Unreleased].

Still open

  • DB integration + template-smoke jobs run in CI (need Docker/Postgres); will confirm green there.

isala404 added 6 commits May 31, 2026 13:38
The 10 attribute macros each copy-pasted the same darling parse scaffold,
duration parsing, and rate-limit extraction. Extract three shared helpers
(parse_attrs, parse_optional_duration, extract_rate_limit) and route
query/mutation/job/mcp_tool/daemon/workflow through them. Removes ~120 lines
of duplication and a redundant rate-limit-key re-check in mcp_tool, with no
behavior change.
The HandlerContext/AuthenticatedContext/Sealed impls were 120+ lines of
hand-written pass-through boilerplate across 8 context types. Replace with
three small macro_rules! generators, keeping MutationContext's bespoke db()
explicit. Same impls, ~90 fewer lines.
All five stores (connection/query/subscription/job/workflow) plus the
optimistic-mutation helper hand-rolled the same Set<subscriber>+notify()+
subscribe() plumbing. Introduce createStoreCore<T> (get/set/update/subscribe
with an onLastUnsubscribe hook) and route every store through it. Teardown
and callback-ordering semantics preserved exactly; tsc --strict clean.
…macros

The eight Test*ContextBuilder types copied byte-for-byte identical auth
(as_user/as_subject/with_role/with_roles/with_claim), env (with_env/with_envs/
with_pool), and tenant (with_tenant) setters. Extract three macro_rules!
generators in context/mod.rs and have each builder opt into the clusters it
supports. No public API change; 583 forge-core tests pass.
…tion init

run() mutated self.config.gateway.port in place from the PORT env var, leaving
the owned config inconsistent with how it was built. Resolve it into a local
effective_port instead. Also lift the self-contained telemetry and migration
prologue out of the 900-line run() into init_telemetry_subsystem() and
apply_migrations(). The intricate cluster/worker/gateway wiring is left intact
since it can only be safely validated by full integration tests.
The geoip feature bundled both the runtime MaxMind MMDB reader and the
build-time-downloaded DB-IP country database, so it couldn't build offline and
was excluded from the default 'full' preset entirely. Split them:

- geoip (now in 'full'): pure-Rust maxminddb reader, offline-safe. Set
  signals.geoip_db_path to a GeoLite2-City MMDB for country/city enrichment.
- geoip-embedded (opt-in): bakes in the DB-IP country DB; the only geoip
  option needing a build-time network fetch.

GeoIpResolver gains a no-data Empty backend for the geoip-without-embedded
case. Breaking: zero-config country enrichment now requires geoip-embedded.
Updates binary-size + signals docs, skill api/frontend references, CHANGELOG.
@isala404 isala404 merged commit 4bf89a3 into main Jun 5, 2026
16 checks passed
@isala404 isala404 deleted the codebase-cleanup-optimization branch June 5, 2026 12:13
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