Skip to content

feat: add shared Context extensions (RFD 61) - #21

Merged
samifouad merged 1 commit into
mainfrom
rfd61/context-extensions
Sep 12, 2026
Merged

samifouad merged 1 commit into
mainfrom
rfd61/context-extensions

Conversation

@samifouad

Copy link
Copy Markdown
Member

Dispatchers can now attach consumer-owned state to Context before handing it to command and subcommand handlers. Extensions stores TypeId -> Arc<dyn Any + Send + Sync> and exposes insert<T>() and get<T>() -> Option<&T> through extensions() / extensions_mut().

Context retains Clone, Debug, Send, and Sync. Clones copy the map and share values through cheap Arc clones, so stored types need neither Clone nor Debug. Replacing an entry affects only that context's map. The borrowed getter avoids an Arc clone for handler reads. README and API docs describe these semantics; consumers using struct literals must migrate to Context::new(args) and assign env as needed.

Validation and consolidated QA/seam review:

  • All five extension tests pass: roundtrip/replacement, type/context isolation, command/subcommand handoff, Send + Sync, and clone pointer identity/shared mutation/local replacement. The existing args/cwd bridge test also passes.
  • cargo check --locked --target wasm32-unknown-unknown --no-default-features --features registry passes.
  • cargo clippy --locked --all-targets -- -D warnings passes; changed Rust files pass rustfmt checks and git diff --check passes.
  • cargo test --locked was run but is not green: the unchanged concurrent token-write test fails with temporary-file collisions. Reproduced independently on origin/main (ead2d1a) with cargo test --locked --test token_file_hardening. Parallel runs also encountered existing update health-probe timeouts; the initially failing probe passes in isolation.
  • cargo test --locked -- --test-threads=1 --skip concurrent_writes_leave_a_complete_private_token_and_no_temp_files passes. No unrelated token-file or timeout code is changed.

Refs dekaruntime/rfd#61.

-codex

@samifouad
samifouad merged commit 3f9e5f6 into main Sep 12, 2026
4 checks passed
@samifouad
samifouad deleted the rfd61/context-extensions branch September 12, 2026 08:25

This branch was successfully deployed

1 active deployment
public-ci — 29ec03d0 Deployed Sep 12, 2026 by samifouad via Build and test #22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant