refactor(hero_biz_admin): purge BASE_PATH env var (home#230 phase 2.1 ref impl) #49
No reviewers
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_biz!49
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_mik_basepath_purge"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Reference implementation for home#230 phase 2 BASE_PATH purge. Per the
hero_web_prefixskill (line 38): "There is noBASE_PATHenvironment variable. The proxy is the only source of truth for the prefix." TheX-Forwarded-Prefixheader from hero_router is captured per-request byprefix_middlewareinto theREQUEST_PREFIXtask-local; direct access (no header) yields""so links stay bare.Changes (commit 1 —
7c41389)pub base_path: String,field fromAppState.std::env::var("BASE_PATH")read atweb/server.rs:122and the corresponding field in theAppStateliteral.effective_base_path()to drop its&AppStateparameter and thestate.base_path.clone()fallback; default to"".web/handlers/mod.rsfromeffective_base_path(&state)toeffective_base_path(). One handler (login_page) loses its now-unusedState<Arc<AppState>>extractor.Pre-flight verification
hero_router/src/server/routes.rs:
("X-Forwarded-Prefix", "/{service}/{webname}")for/<svc>/<webname>/...paths("X-Forwarded-Prefix", "/{service}/rpc")for/<svc>/rpc/...pathsSo the env-var path was dead-letter — the header is correctly injected on every routed request.
Companion changes
BASE_PATHfromservice_biz.nuenv block (supersedes c0186425)BASE_PATHfromservices/hero_biz.tomldevelopment_mik_service_manager_v2); origin/development of hero_router has no Rust-side BASE_PATH env injection.Commit 2 — clippy debt clearance (
40eaa41)Pre-existing rust-1.95 lint debt from upstream toolchain bump (
53a52a1). Bundled here so the workspace pre-merge gate (feedback_workspace_build_before_merge.md) passes:search/fuzzy.rs:240:sort_by→sort_by_key(|r| Reverse(r.score))perunnecessary_sort_byweb/templates/mod.rs6 sites:if total == 0 { 0 } else { (done * 100 / total) as u8 }→(done * 100).checked_div(total).unwrap_or(0) as u8permanual_checked_opsTest plan
cargo fmt --checkgreencargo clippy --workspace --all-targets -- -D warningsgreencargo build --workspace --releasegreen (exit 0)service_biz install --download --version v0.5.0-rc1 --reset+ browser smoke athttps://herodemo.gent01.grid.tf/hero_biz/admin/— links should render with/hero_biz/admin/prefix; direct UDS access viacurl --unix-socket .../admin.sock http://localhost/c/threefoldshould render bare-rooted links.Refs
~/.claude/skills/hero_web_prefix/SKILL.mdline 38Signed-off-by: mik-tf
Per the `hero_web_prefix` skill (line 38): "There is no `BASE_PATH` environment variable. The proxy is the only source of truth for the prefix." The header `X-Forwarded-Prefix` is injected by hero_router on every routed request and captured per-request by `prefix_middleware` into the `REQUEST_PREFIX` task-local; direct access (no header) yields `""` so all links stay bare. There is no scenario where reading from `std::env::var("BASE_PATH")` produces a correct value that the header path doesn't already produce. Changes: - Drop `pub base_path: String,` field from `AppState`. - Drop the `std::env::var("BASE_PATH")` read at `web/server.rs:122` and the corresponding `base_path,` field in the `AppState` literal. - Rewrite `effective_base_path()` to drop its `&AppState` parameter and the `state.base_path.clone()` fallback; default to `""` when no `X-Forwarded-Prefix` is present. - Update all 166 call sites in `web/handlers/mod.rs` from `effective_base_path(&state)` to `effective_base_path()` (mechanical sed-rewrite, plus one `login_page` handler signature simplification to drop the now-unused `State<Arc<AppState>>` extractor). Verified via hero_router source audit (`hero_router/src/server/routes.rs` lines 669+677 for `/<svc>/<webname>/...` paths and 1274+1281 for `/<svc>/rpc/...` paths) that `X-Forwarded-Prefix` is set on every forwarded request — the env-var path was dead-letter. Reference implementation for home#230 phase 2; same shape will apply to hero_foundry, hero_agent, hero_embedder, hero_code, hero_proc. Companion changes ride in: - hero_skills service_biz.nu (drop BASE_PATH env block — supersedes c0186425) - hero_demo services/hero_biz.toml (drop BASE_PATH env line) - hero_router service_manager/services/hero_biz.rs (drop ("BASE_PATH", ...) launch-time env tuple) Refs: - lhumina_code/home#230 — alignment audit META - lhumina_code/home#225 — META rule umbrella - ~/.claude/skills/hero_web_prefix/SKILL.md line 38 Signed-off-by: mik-tf