Memoize env-keyed subprocess probes through one helper: composer, python and ruby each define the same env key and drifted on when an answer is kept
维护者通常 1 天内回复
评估
调研方向
Read crates/socket-patch-core/src/crawlers/composer_crawler.rs, python_crawler.rs, and ruby_crawler.rs, then inspect the shared process utilities in utils/process.rs. Compare the memoization rules and tests named in the issue, especially the environment-change keep rule. Done when the three crawlers use the shared helper and the listed tests, including a test for changed environments, pass; pull request #1895 is already open.
由索引模型根据 Issue 内容生成。
描述
[agent] Filed by the scheduled architecture audit (audit-core). Register: register.
Kind: refactor. Register ID: A32.
Problem
Three crawlers memoize a subprocess answer (composer config, the Python site query, gem env), keyed on the sorted process environment plus the cwd. The key function is byte-identical in all three:
let mut vars: Vec<_> = std::env::vars_os().collect();
vars.sort();
(vars, std::env::current_dir().ok())
- composer:
EnvKeyedMemo+env_key, composer_crawler.rs L477-L550.`` It is a single slot, and it keeps an answer only if the environment is unchanged after the subprocess returns. - python:
KeyedMemo<K, V>+site_query_key, python_crawler.rs L2765-L2817.```` It is a single slot and stores every answer (let value = run()?; *lock() = Some((key, value.clone()))). It has no env-unchanged check, so an answer computed while another thread changed the environment is filed under the old key. - ruby:
GemEnvMemo(aHashMapofOnceCells) +gem_env_key, ruby_crawler.rs L1012-L1023 and L1625-L1650.`````` It keeps every key it has ever seen, never evicts, single-flights per key, and has composer's env-unchanged check.
The drift (python's missing env-unchanged check) comes from reading the code; I did not execute it. It only matters when tests or the CLI change env concurrently.
Proposed change
- Add one
utils::process::EnvKeyedMemo<V>with anenv_key(). Use a single slot and composer's rule: keep an answer only when the env is unchanged after the run. - Composer and python use it directly.
- Ruby's async single-flight can wrap the same key type and keep-rule. Alternatively, ruby's map can become the single slot, since no caller needs more than one environment at a time.
- Delete the three key functions and the two memo structs.
Size
3 files plus utils/process.rs, about −60 lines.
Acceptance criteria
- Behavior is unchanged. Composer's
get_or_run_keyedtests, python's memo test (python_crawler.rs ~L8126) and ruby'smemoize_gem_env_homestests must stay green and move to the shared helper. - One test covers the keep rule: an answer computed while the env changed is not cached.
- 主要语言
- Rust
- 星标
- 8
- 派生
- 2
- 平均合并
- 19 小时 12 分钟
- 30 天内合并 PR
- 709
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged arch-audit priority:p3 refactor
难度 2/5 1-3 小时 新手友好度 83/100
SocketDev/socket-patch#1860 ·
维护者通常 1 天内回复
-
agent:triaged arch-audit priority:p3 refactor
难度 2/5 1-3 小时 新手友好度 78/100
SocketDev/socket-patch#1838 ·
维护者通常 1 天内回复
-
Share one scoped env-var test guard: EnvGuard is copy-pasted 11 times across core unit and integration tests可能已有人在做 @mikolalysenko 于 1 天前认领。 未关闭agent:claimed agent:triaged arch-audit priority:p3 refactor
难度 4/5 3-5 天 新手友好度 55/100
SocketDev/socket-patch#1889 · 2 条评论 ·
维护者通常 1 天内回复
-
agent:triaged arch-audit priority:p3 refactor
难度 4/5 1-2 天 新手友好度 55/100
SocketDev/socket-patch#1887 · 1 条评论 ·
维护者通常 1 天内回复
-
agent:needs-human agent:triaged arch-audit priority:p3 refactor
难度 4/5 3-5 天 新手友好度 38/100
SocketDev/socket-patch#1881 ·
维护者通常 1 天内回复
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
good first issue help wanted
难度 2/5 1-3 小时 新手友好度 72/100
servo/rust-smallvec#827 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
nowledge-co/hawdb#1400 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
calcit-lang/caps#16 ·
-
难度 2/5 1-3 小时 新手友好度 85/100
penso/herdr-gpui#934 ·
维护者通常 1 天内回复
-
🎉 Add Bossanova未关闭
难度 2/5 1-3 小时 新手友好度 70/100
jaywcjlove/awesome-mac#4096 ·
维护者通常 1 天内回复