Skip to content

Commit 9a4f60e

Browse files
committed
refactor: simplify lpb.py — image is the configuration reference
- Remove runtime env var overrides for LPB_PI_REF/LPB_CONFIG_REF - The image is built with baked-in LPB_PI_REF (version tag) - lpb.py just selects which pre-built image to use - --tag dev/main/latest selects the image pipeline - --version 0.0.9-lpb pins to exact version image - No runtime override — reproducible by design - Remove unused _resolve_config_profile/version functions
1 parent 9e6a4d7 commit 9a4f60e

1 file changed

Lines changed: 5 additions & 57 deletions

File tree

‎scripts/lpb.py‎

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -161,42 +161,6 @@ def resolve_web_image(tag: str) -> str:
161161
return WEB_IMAGE
162162

163163

164-
# ─── Config profile selection (dev vs main) ───────────────────────────
165-
# When --tag dev or --tag main is used, override LPB_PI_REF and
166-
# LPB_CONFIG_REF to point to the appropriate branches.
167-
def _resolve_config_profile(tag: str) -> dict[str, str] | None:
168-
"""Return config overrides based on image tag.
169-
170-
Returns None for custom tags (e.g. mybranch, sha).
171-
172-
Branch mapping:
173-
--tag dev → LPB_PI_REF=lpb-dev, LPB_CONFIG_REF=dev
174-
--tag main → LPB_PI_REF=lpb, LPB_CONFIG_REF=main
175-
--tag latest → LPB_PI_REF=lpb, LPB_CONFIG_REF=main (same as main)
176-
--tag <x> → no overrides (custom/PR images use defaults)
177-
"""
178-
if tag == "dev":
179-
return {"LPB_PI_REF": "lpb-dev", "LPB_CONFIG_REF": "dev"}
180-
elif tag == "main" or tag == "latest":
181-
return {"LPB_PI_REF": "lpb", "LPB_CONFIG_REF": "main"}
182-
return None
183-
184-
185-
def _resolve_config_version(version: str) -> dict[str, str] | None:
186-
"""Return config overrides when --version is used to pin a specific tag.
187-
188-
When --version 0.0.9-lpb is used, the container should clone
189-
that specific version tag instead of a branch.
190-
191-
Returns {"LPB_PI_REF": version, "LPB_CONFIG_REF": version} so the
192-
container clones the pi and config repos at that exact commit.
193-
"""
194-
# Only pin if it looks like a version tag (starts with 0.0. or v)
195-
if version and (version.startswith("0.0.") or version.startswith("v")):
196-
return {"LPB_PI_REF": version, "LPB_CONFIG_REF": version}
197-
return None
198-
199-
200164
# ─── Load runtime configuration ──────────────────────────────────────────
201165
# lpb.conf.env defines runtime defaults (editor, browser, LLM, persistence)
202166
# Loaded after stack env — workspace .env overrides both.
@@ -666,7 +630,7 @@ def _build_parser() -> argparse.ArgumentParser:
666630
parser.add_argument("--ssh", nargs="?", const="", metavar="PUBKEY")
667631
parser.add_argument("--web", action="store_true")
668632
parser.add_argument("--tag", default=None,
669-
help="Image tag to use (dev|main|latest|<custom>)")
633+
help="Select image pipeline (dev|main|latest|<custom>)")
670634
parser.add_argument("--version", nargs="?", const="_show",
671635
help="Pin to version tag (e.g. 0.0.9-lpb) or show stack version")
672636
parser.add_argument("--stop", "-s", action="store_true")
@@ -724,7 +688,6 @@ def parse_cli(args: list[str]) -> None:
724688
else:
725689
# --version 0.0.9-lpb → pin to specific version tag
726690
cfg.image_tag = known.version # uses :0.0.9-lpb-cli
727-
# LPB_PI_REF will be set by _resolve_config_version() below
728691
if known.stop:
729692
cfg.command = "stop"
730693
if known.remove:
@@ -1130,31 +1093,16 @@ def cmd_run():
11301093
# lpb prints matches the token the VSCodium server actually enforces.
11311094
ensure_token()
11321095

1133-
# Apply config overrides (version > profile > defaults)
1134-
# --version 0.0.9-lpb takes priority over --tag dev/main
1135-
if tag and re.match(r'^[0-9]+\.[0-9]+\.[0-9]+', tag):
1136-
# Version tag (e.g. 0.0.9-lpb) — pin to exact commit
1137-
version_cfg = _resolve_config_version(tag)
1138-
if version_cfg:
1139-
profile = version_cfg
1140-
info(f" Config: pinned to version {tag}")
1141-
info(f" LPB_PI_REF={profile['LPB_PI_REF']}, LPB_CONFIG_REF={profile['LPB_CONFIG_REF']}")
1142-
else:
1143-
info(f" Config: custom (using defaults)")
1144-
elif profile := _resolve_config_profile(tag):
1145-
info(f" Config: {tag} profile (LPB_PI_REF={profile['LPB_PI_REF']}, LPB_CONFIG_REF={profile['LPB_CONFIG_REF']})")
1146-
else:
1147-
info(f" Config: custom (using defaults)")
1148-
11491096
env_vars = [
11501097
f"LPB_ED_PORT={cfg.port}",
11511098
f"LPB_EDITOR_HOST={cfg.host}",
11521099
f"LPB_DEVCONTAINER_WORKSPACE_DIR={mount_path}",
11531100
f"LPB_CONNECTION_TOKEN={cfg.token}",
11541101
f"CONNECTION_TOKEN={cfg.token}",
1155-
# Config profile overrides (applied based on --tag)
1156-
f"LPB_PI_REF={profile['LPB_PI_REF']}" if profile else "",
1157-
f"LPB_CONFIG_REF={profile['LPB_CONFIG_REF']}" if profile else "",
1102+
# NOTE: LPB_PI_REF and LPB_CONFIG_REF are NOT passed as env vars.
1103+
# The image is built with these baked in (LPB_PI_REF is the version
1104+
# tag or branch ref). The image IS the configuration reference —
1105+
# lpb.py just selects which pre-built image to use.
11581106
# Note: LPB_STATE_DIR is NOT passed to the container. It's a launcher-time
11591107
# config (lpb.py reads it to resolve the host mount source). The container
11601108
# has no need for it — start.sh uses its own defaults. Passing it here

0 commit comments

Comments
 (0)