feat: deepen ACTION scope behind action_scope(ctx)#15
Merged
Conversation
Add a public `action_scope(ctx)` context manager that yields a fresh ACTION-scoped container (a child of the command's REQUEST container). Commands no longer inject `modern_di.Container` and call `build_child_container()` by hand to reach ACTION scope. Multiple actions per command are preserved: each `with action_scope(ctx)` block is its own action scope, so a command can open one per unit of work. `@inject` now always builds the per-command REQUEST container and stashes it on `ctx.meta`, so `action_scope` can parent the ACTION container onto it. Request-scoped singletons are therefore shared between injected params and deps resolved inside an action scope. The manual `FromDI(Container)` + `build_child_container()` pattern still works and remains tested. Also correct stale CLAUDE.md architecture notes (module-global `_container`, public `build_command_container`) and add CONTEXT.md naming the app container / command container / action scope seams. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…TEXT.md Replace the single CONTEXT.md with the portable two-axis planning convention from lesnik512/planning-convention (v1.0.0), as applied in the sibling modern-di repo: - architecture/ — living capability truth (README, scopes.md, injection.md), the promotion target on every ship. - planning/ — .convention-version, README (portable convention), index.py validator/indexer, _templates/ (change/design/plan/decision/release), changes/, decisions/, deferred.md. Seed it with the real artifacts for this branch's feature: the 2026-06-25.01-action-scope change bundle (design.md + plan.md) and the action-scope-multiple-actions-per-command decision. deferred.md records the still-open ctx.obj container-seam candidate from the architecture review. Wire-up: lint-ci runs `planning/index.py --check`; add `just index` / `just check-planning`; CLAUDE.md points at architecture/ and planning/. index.py is copied from canonical; only its ruff-noqa comment is adapted to this repo's lint config (D213 ignored, so D212 is suppressed), matching how modern-di adapts it. planning/index.py is never imported, so test-ci's `--cov=.` 100% gate is unaffected. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Two things, on one branch:
Feature — a public
action_scope(ctx)context manager so commands reachScope.ACTIONdependencies without touchingmodern_di's container interface:Planning convention — adopt the portable two-axis convention from
lesnik512/planning-convention(v1.0.0), as applied in the siblingmodern-direpo, replacing the singleCONTEXT.md.Feature: deepen ACTION scope
Before, ACTION scope leaked
build_child_container()to every call site (the command injectedmodern_di.Containerand built a child by hand). REQUEST scope was deep behind@inject; ACTION was shallow. This pulls scope-nesting behind one named interface — leverage (one interface for every scope) and locality (nesting lives inaction_scope).with action_scope(ctx)block is its own ACTION container (the loop case ACTION exists for). Seeplanning/decisions/2026-06-25-action-scope-multiple-actions-per-command.md.@injectnow always builds the per-command REQUEST container and stashes it onctx.meta(per-invocation, isolated — notctx.obj, shared app state), so request-scoped singletons are shared between injected params and action-resolved deps.FromDI(Container)pattern still works and stays tested (backward compatible).Planning convention
architecture/— living capability truth (scopes.md,injection.md); the promotion target.planning/—.convention-version, README,index.pyvalidator/indexer,_templates/,changes/,decisions/,deferred.md.2026-06-25.01-action-scopebundle + decision);deferred.mdrecords the still-openctx.objcontainer-seam candidate.lint-cirunsplanning/index.py --check; addsjust index/just check-planning; CLAUDE.md points atarchitecture/andplanning/.Verification
just test-ci— 11 passed, 100% coverage (planning/index.pyis never imported, so the--cov=.gate is unaffected).just lint-ciclean (ruff + planning validation).just check-planning→planning: OK.🤖 Generated with Claude Code