-
Notifications
You must be signed in to change notification settings - Fork 15
Tooling skills n config from mtf dev #461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
61f9b62
Ignore notes & snippets subdirs in `git`
goodboy bca7f10
Reorganize `.gitignore` by skill/purpose
goodboy dca7967
Add `lastfailed` cache inspection to `/run-tests` skill
goodboy fae2525
Expand `/run-tests` venv pre-flight to cover all cases
goodboy c72dc8c
Bump `xonsh` to latest pre `0.23` release
goodboy e8e4657
Pin `xonsh` to GH `main` in editable mode
goodboy ba111b3
Split py-version-gated uv dependency-groups
goodboy 47ac8c0
Avoid skip `.ipc._ringbuf` import when no `cffi`
goodboy e5d4d94
Import-or-skip `.devx.` tests requiring `greenback`
goodboy fc3ab95
Add global 200s `pytest-timeout`
goodboy c170007
Add zombie-actor check to `run-tests` skill
goodboy 974cb15
Use SIGINT-first ladder in `run-tests` cleanup
goodboy a26619d
Claude-perms: ensure /commit-msg files can be written!
goodboy cda9423
Codify capture-pipe hang lesson in skills
goodboy 4e9f392
Drop global `pytest-timeout` cap from `pyproject.toml`
goodboy 8c6b7fd
Add posix-multithreaded-`fork()` explainer doc
goodboy 3dc3f84
Flip back to default `pytest` capture for CI
goodboy 3f18caa
Add `test_register_duplicate_name` race analysis
goodboy 0a3772c
Add `RuntimeVars` env-var lift design plan
goodboy 9defec4
Bump to latest `pytest` release!
goodboy cec0731
Mk `test_no_runtime()` not require `pytest-trio`
goodboy dd65194
Add `logspec` leaf-mod Route B follow-up doc
goodboy 6b0cb17
Address Copilot review nits on PR #461
goodboy 9f1a64f
Relock `uv.lock` for py3.13+ & `pytest` CVE
goodboy c5feeac
Pin `pytest>=9.0.3` for CVE-2025-71176 floor
goodboy c0fdfa4
Pin sdist-install step to py3.13
goodboy 26f2b23
Address Copilot review nits on PR #461 (round 2)
goodboy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| # `RuntimeVars` env-var lift — design plan | ||
|
|
||
| Status: **draft, awaiting user edits** | ||
|
|
||
| ## Goal | ||
|
|
||
| Consolidate the sprawl of pytest CLI flags + ad-hoc env vars + | ||
| hardcoded fixture defaults into a *single* env-var-encoded | ||
| runtime-vars envelope, with a typed in-memory representation | ||
| (`tractor.runtime._state.RuntimeVars`) as the sole source of | ||
| truth. | ||
|
|
||
| ## Why now | ||
|
|
||
| - `--tpt-proto`, `--spawn-backend`, `--diag-on-hang`, | ||
| `--diag-capture-delay` and (soon) `TRACTOR_REG_ADDR` etc. are | ||
| proliferating. Each adds a parsing seam. | ||
| - `tests/devx/test_debugger.py` invokes example scripts as | ||
| separate subprocesses; they currently can't see the | ||
| fixture-allocated `reg_addr` at all (root cause of why | ||
| parametrizing devx scripts on `reg_addr` is on your TODO). | ||
| - Concurrent pytest sessions on the same host collide on | ||
| shared defaults (the `registry@1616` race we just fixed is | ||
| one symptom; per-session unique addr is the structural | ||
| fix). | ||
| - `tractor.runtime._state.RuntimeVars: Struct` is already | ||
| defined and **unused** — its docstring even says it | ||
| "should be utilized as possible for future calls." | ||
|
|
||
| ## Design | ||
|
|
||
| ### Module: `tractor/_testing/_rtvars.py` | ||
|
|
||
| Lifted from `modden.runtime.env`, ~50 LOC, no new deps. | ||
|
|
||
| ```python | ||
| _TRACTOR_RT_VARS_OSENV: str = '_TRACTOR_RT_VARS' | ||
|
|
||
| def dump_rtvars(rtvars: RuntimeVars|dict) -> tuple[str, str]: | ||
| '''str-serialize via `str(dict)` — ast.literal_eval-able''' | ||
|
|
||
| def load_rtvars(env: dict) -> RuntimeVars: | ||
| '''ast.literal_eval the env-var value, hydrate to struct''' | ||
|
|
||
| def get_rtvars(proc: psutil.Process|None = None) -> RuntimeVars: | ||
| '''read the var from a target proc's env (or current)''' | ||
|
|
||
| def update_rtvars( | ||
| rtvars: RuntimeVars|dict|None = None, | ||
| update_osenv: bool|dict = True, | ||
| ) -> tuple[str, str]: | ||
| '''mutate + re-encode + (optionally) write to os.environ''' | ||
| ``` | ||
|
|
||
| ### Encoding choice: `str(dict)` + `ast.literal_eval` | ||
|
|
||
| Pros: | ||
| - stdlib only | ||
| - handles all the types tractor's tests need: `str`, `int`, | ||
| `float`, `bool`, `None`, `list`, `tuple`, `dict` | ||
| - human-readable in the env (greppable, inspectable via | ||
| `cat /proc/<pid>/environ | tr '\0' '\n'`) | ||
|
|
||
| Cons: | ||
| - non-stdlib types (msgspec Structs, `Path`, custom classes) | ||
| must be lowered first — fine for the test fixture set | ||
| - not stable across Python versions for esoteric repr cases | ||
| (we don't hit any) | ||
|
|
||
| Alternatives considered: | ||
| - **msgpack**: adds a dep + binary form is ungreppable | ||
| - **json**: doesn't preserve tuples (becomes lists), which is | ||
| a common type for `reg_addr` | ||
| - **toml/yaml**: heavier deps, no real benefit | ||
|
|
||
| ### `RuntimeVars` becomes the single source of truth | ||
|
|
||
| The legacy `_runtime_vars: dict[str, Any]` global in | ||
| `runtime/_state.py` becomes a *cached view* of a | ||
| `RuntimeVars` singleton instance: | ||
|
|
||
| - `get_runtime_vars()` returns either the struct or a | ||
| `.to_dict()` view depending on caller's preference | ||
| - `set_runtime_vars(...)` validates against the struct schema | ||
| - spawn-time SpawnSpec sends the struct (already does | ||
| conceptually — just gets typed) | ||
| - `__setattr__` `breakpoint()` debug instrumentation gets | ||
| removed (unrelated cleanup, mentioned in conversation) | ||
|
|
||
| ### Migration path | ||
|
|
||
| **Phase 0** *(prep)*: strip the stray `breakpoint()` from | ||
| `RuntimeVars.__setattr__`. | ||
|
|
||
| **Phase 1**: land `_rtvars.py` as a leaf module, used only by | ||
| test infra. Subprocess-spawned scripts in `tests/devx/` | ||
| read `_TRACTOR_RT_VARS` on startup → reconstruct | ||
| `RuntimeVars` → call `tractor.open_root_actor(**rtvars.as_kwargs())`. | ||
| Concurrent runs become deterministic-isolated because each | ||
| session writes a unique `_registry_addrs` into the env. | ||
|
|
||
| **Phase 2**: migrate runtime callers (`_state.get_runtime_vars`, | ||
| spawn `SpawnSpec`, `Actor.async_main`) to operate on the | ||
| struct directly, with the dict as a compat view that gets | ||
| deprecated. | ||
|
|
||
| **Phase 3** *(structural)*: per-session bindspace subdir | ||
| `/run/user/<uid>/tractor/<session_uuid>/` — encoded in the | ||
| rt-vars envelope, picked up by every subactor automatically. | ||
| Obsoletes the entire bindspace-leak warning class. | ||
|
|
||
| ## Open design questions (user input wanted) | ||
|
|
||
| - (placeholder for your edits) | ||
| - (placeholder) | ||
| - (placeholder) | ||
|
|
||
| ## Out-of-scope for this lift | ||
|
|
||
| - Anything in `modden.runtime.env` related to `Spawn`, | ||
| `WmCtl`, `Wks` — that's a workspace orchestration layer, | ||
| not an env-var helper. We only lift the four utility | ||
| functions + the var name constant. | ||
| - Switching to msgpack/json — explicitly chosen against | ||
| above. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Intentional for now — this is a local-only
settings.local.json(per-dev convenience, not shippedpolicy). The suite reads many transient
/tmpartifactsbeyond the registry socks (pytest's
/tmp/pytest-*, UDSbinds, stackscope dumps), so a blanket
Read(/tmp/**)avoids whack-a-mole on patterns. Can tighten later if we
formalize a shared policy.