semantics: complete DEF-to-region migration, fix regressions
- Convert legacy [DEF🆔Type] anchors to #region/#endregion across 329 files
- Reinstate _normalize_timestamp_value in sql_generator.py
- Fix MarkerLogger→logger migration in events.py (molecular CoT markers)
- Fix dataset_review orchestrator dependencies (_build_execution_snapshot)
- Fix config_manager stale-record deletion (moved to save path only)
- Add 77 missing [/DEF:] closers in 5 unbalanced test files
- Update assistant_chat.integration.test.js for #region format
- Apply molecular-cot-logging markers (REASON/REFLECT/EXPLORE) via logger.* methods
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
# #region EncryptionKeyModule [C:5] [TYPE Module] [SEMANTICS encryption, key, bootstrap, environment, startup]
|
||||
# @BRIEF Resolve and persist the Fernet encryption key required by runtime services.
|
||||
# @LAYER Infra
|
||||
# @PRE Runtime environment can read process variables and target .env path is writable when key generation is required.
|
||||
# @POST A valid Fernet key is available to runtime services via ENCRYPTION_KEY.
|
||||
# @SIDE_EFFECT May append ENCRYPTION_KEY entry into backend .env file and set process environment variable.
|
||||
# @DATA_CONTRACT Input[env_file_path] -> Output[encryption_key]
|
||||
# @INVARIANT Runtime key resolution never falls back to an ephemeral secret.
|
||||
# @LAYER: Infra
|
||||
# @RELATION DEPENDS_ON -> [LoggerModule]
|
||||
# @INVARIANT: Runtime key resolution never falls back to an ephemeral secret.
|
||||
# @PRE: Runtime environment can read process variables and target .env path is writable when key generation is required.
|
||||
# @POST: A valid Fernet key is available to runtime services via ENCRYPTION_KEY.
|
||||
# @SIDE_EFFECT: May append ENCRYPTION_KEY entry into backend .env file and set process environment variable.
|
||||
# @DATA_CONTRACT: Input[env_file_path] -> Output[encryption_key]
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -22,9 +22,9 @@ DEFAULT_ENV_FILE_PATH = Path(__file__).resolve().parents[2] / ".env"
|
||||
|
||||
# #region ensure_encryption_key [TYPE Function]
|
||||
# @BRIEF Ensure backend runtime has a persistent valid Fernet key.
|
||||
# @PRE env_file_path points to a writable backend .env file or ENCRYPTION_KEY exists in process environment.
|
||||
# @POST Returns a valid Fernet key and guarantees it is present in process environment.
|
||||
# @SIDE_EFFECT May create or append backend/.env when key is missing.
|
||||
# @PRE: env_file_path points to a writable backend .env file or ENCRYPTION_KEY exists in process environment.
|
||||
# @POST: Returns a valid Fernet key and guarantees it is present in process environment.
|
||||
# @SIDE_EFFECT: May create or append backend/.env when key is missing.
|
||||
def ensure_encryption_key(env_file_path: Path = DEFAULT_ENV_FILE_PATH) -> str:
|
||||
with belief_scope("ensure_encryption_key", f"env_file_path={env_file_path}"):
|
||||
existing_key = os.getenv("ENCRYPTION_KEY", "").strip()
|
||||
|
||||
Reference in New Issue
Block a user