Skip to content

refactor(b08): explicit startup config normalization; import no longer mutates os.environ - #590

Merged
Pigbibi merged 1 commit into
mainfrom
rebuild/b08-lb-explicit-config
Oct 11, 2026
Merged

Pigbibi merged 1 commit into
mainfrom
rebuild/b08-lb-explicit-config

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Summary — B08 batch 1 (QSL-MODULAR-AUDIT §10: "显式化配置解析;先保持原归一化行为,采用值有回执,模块 import 不改 os.environ;默认策略变化另开 PR")

  • New pure module application/startup_config.py: normalize_plugin_mounts_strategy, normalize_monitor_dispatch_targets, overlay_env, ConfigCorrection, StartupConfigReceipt. No os.environ reads/writes inside.
  • main.py import no longer writes os.environ[MONITOR_DISPATCH_TARGETS_JSON | LONGBRIDGE_MONITOR_DISPATCH_TARGETS_JSON]. Corrections are kept in MONITOR_DISPATCH_ENV_OVERRIDES; /monitor-dispatch reads through overlay_env(os.environ, overrides) (only consumer of these names in LB). With no corrections the call is byte-identical to before (load_monitor_targets()).
  • Frozen PlatformRuntimeSettings is dataclasses.replace()d instead of object.__setattr__ (non-dataclass test doubles still use setattr).
  • Receipt: STARTUP_CONFIG_RECEIPT (profile, each correction source/field/original/adopted, overridden env names). [config-sync] … log lines unchanged.

Parity

  • tests/test_startup_config.py keeps verbatim copies of the pre-B08 inline logic (main@fe16142) and checks 9 plugin-mount inputs + 8 env inputs (malformed JSON, non-dict, non-list, matching/non-matching profiles, non-ASCII, mixed entries): same output, same log lines, input env not mutated.
  • Import test: wrong profile in MONITOR_DISPATCH_TARGETS_JSON → os.environ unchanged after import, receipt recorded, dispatcher sees corrected targets.
  • Full suite: 1943 passed.

Not in scope

No default-strategy change, no HK scheduler / enable-hk-* / PAUSED-resume change, no env/secret/traffic/deploy. Remaining B08 work: rest of module-level config resolution in main.py (RUNTIME_SETTINGS → STRATEGY_RUNTIME globals) into an explicit startup context.

Author: Pigbibi.

…s.environ writes

- move plugin-mount / monitor-dispatch strategy_profile normalization into pure
  application/startup_config.py (same rules, same [config-sync] log lines)
- main import no longer writes os.environ; corrected monitor dispatch targets are
  read through an explicit overlay (identical call when nothing was corrected)
- frozen settings are dataclasses.replace()d instead of object.__setattr__
- adopted corrections recorded in STARTUP_CONFIG_RECEIPT
- parity tests against verbatim copies of the pre-B08 inline logic
@Pigbibi
Pigbibi merged commit 8c42d21 into main Oct 11, 2026
1 check passed
@Pigbibi
Pigbibi deleted the rebuild/b08-lb-explicit-config branch October 11, 2026 07:49
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