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
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
[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.
- Linguagem predominante
- Rust
- Estrelas
- 8
- Forks
- 2
- Merge médio
- 19h 12min
- PRs com merge (30d)
- 709
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de SocketDev/socket-patch
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
SocketDev/socket-patch#1860 ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
SocketDev/socket-patch#1838 ·
Mantenedores costumam responder em até 1 dia
-
Share one scoped env-var test guard: EnvGuard is copy-pasted 11 times across core unit and integration testsTalvez já em andamento @mikolalysenko assumiu hoje. Abertaagent:claimed agent:triaged arch-audit priority:p3 refactor
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 55/100
SocketDev/socket-patch#1889 · 2 comentários ·
Mantenedores costumam responder em até 1 dia
-
agent:triaged arch-audit priority:p3 refactor
Dificuldade 4/5 1-2 dias Facilidade para iniciantes 55/100
SocketDev/socket-patch#1887 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
agent:needs-human agent:triaged arch-audit priority:p3 refactor
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 38/100
SocketDev/socket-patch#1881 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de SocketDev/socket-patch
Issues semelhantes
-
bug priority: low ui
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
storytold/photocraft#10370 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
area:doc bug in progress needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
bherbruck/solvecraft#9634 · 2 comentários · 1 reação ·
-
inflate: total_in uses plain += on c_ulong (32-bit on Windows), panics in debug for streams > 4 GiBAberta
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
trifectatechfoundation/zlib-rs#570 · 1 comentário ·
-
bug discord-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
LanternOps/breeze#10755 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
aranya-project/aranya#803 ·