|
| 1 | +Environment-Scoped Typed Asset Store |
| 2 | +==================================== |
| 3 | + |
| 4 | +Flows need centrally-managed config values that differ by environment |
| 5 | +(dev/staging/prod) and carry a type — the orchestrator "Assets / lockers" |
| 6 | +pillar. The secret vault covers secrets only and config-sync moves whole blobs; |
| 7 | +neither offers a typed, per-environment named lookup. ``AssetStore`` fills that: |
| 8 | +values are stored under an environment, read back with type coercion, and |
| 9 | +``credential`` assets hold a *reference* (a secret name) that :meth:`resolve` |
| 10 | +turns into the real value through an injected resolver — so the secret never |
| 11 | +lands in a plain ``get`` or an executor record. |
| 12 | + |
| 13 | +JSON-backed (or in-memory); pure standard library; imports no ``PySide6``. |
| 14 | + |
| 15 | +Headless API |
| 16 | +------------ |
| 17 | + |
| 18 | +.. code-block:: python |
| 19 | +
|
| 20 | + from je_auto_control import AssetStore, active_environment |
| 21 | +
|
| 22 | + store = AssetStore("assets.json") |
| 23 | + store.set("max_retries", 3, asset_type="int", environment="prod") |
| 24 | + store.set("api_base", "https://prod.example.com", environment="prod") |
| 25 | + store.set("db_password", "vault_db_pw", asset_type="credential") # value = a ref |
| 26 | +
|
| 27 | + store.get("max_retries", environment="prod").value # -> 3 (typed) |
| 28 | + store.get("api_base", environment="staging").value # -> falls back to default |
| 29 | + store.get("db_password").value # -> "vault_db_pw" (reference, safe) |
| 30 | +
|
| 31 | + # resolve a credential through an injected secret resolver (Python-only): |
| 32 | + store = AssetStore("assets.json", secret_resolver=secret_manager.get) |
| 33 | + store.resolve("db_password") # -> the real secret |
| 34 | +
|
| 35 | +Types are ``text`` / ``int`` / ``bool`` / ``credential``; ``get`` coerces to the |
| 36 | +declared type and falls back to the ``default`` environment unless disabled. |
| 37 | +``active_environment()`` reads ``JE_AUTOCONTROL_ENV``. ``list`` / ``delete`` round |
| 38 | +out the store. |
| 39 | + |
| 40 | +Executor commands |
| 41 | +----------------- |
| 42 | + |
| 43 | +================================ =================================================== |
| 44 | +Command Effect |
| 45 | +================================ =================================================== |
| 46 | +``AC_set_asset`` Store a typed, environment-scoped asset. |
| 47 | +``AC_get_asset`` Read an asset (credential stays a reference). |
| 48 | +``AC_list_assets`` List ``{name, type, environment}`` (no values). |
| 49 | +================================ =================================================== |
| 50 | + |
| 51 | +Credential **resolution** is intentionally Python-API-only (so secrets never |
| 52 | +enter run records). The same lifecycle operations are exposed as MCP tools |
| 53 | +(``ac_set_asset`` / ``ac_get_asset`` / ``ac_list_assets``) and as Script Builder |
| 54 | +commands under **Data**. |
0 commit comments