Skip to content

Resolve #2279: harden DI request scope lifecycle and introspection ownership#2302

Open
ayden94 wants to merge 4 commits into
mainfrom
issue-2279-close-di-request-scope-lifecycle-and-introspection-ownership-gaps
Open

Resolve #2279: harden DI request scope lifecycle and introspection ownership#2302
ayden94 wants to merge 4 commits into
mainfrom
issue-2279-close-di-request-scope-lifecycle-and-introspection-ownership-gaps

Conversation

@ayden94

@ayden94 ayden94 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Harden @fluojs/di request-scope lifecycle ownership and framework introspection boundaries.

Linked context: Closes #2279

Changes

  • Recursively track and dispose nested request scopes from each owning request-scope container before clearing that owner cache.
  • Replace mutable inspectResolutionState() map exposure with read-only map views, frozen normalized provider records, and controlled cache adoption for framework tooling.
  • Move @fluojs/testing sync cache adoption off direct Map mutation and onto the new container-owned cache adoption seam.
  • Record sync factory resolution kind when @fluojs/testing first materializes a sync factory through get(), so later async sync-points can safely promote dependent sync graphs.
  • Add targeted DI regression tests for nested request-scope disposal, nested descendant override invalidation, stale nested request-scope instance disposal, read-only introspection state, provide: null, and zero-strategy provider validation.
  • Add a testing regression for the sync-first factory path: get(A) materializes a sync factory, resolve(B) follows where B depends on A, then get(B) preserves identity instead of throwing a false async-only error.
  • Update packages/di EN/KO README lifecycle and introspection contract text.
  • Add .changeset/soft-pandas-guard.md for @fluojs/di major release impact and @fluojs/testing patch release impact.

Testing

  • lsp_diagnostics attempted for changed TS files; unavailable in this environment because biome executable was not found by the LSP tool.
  • pnpm install --frozen-lockfile
  • pnpm --dir packages/di typecheck
  • pnpm --dir packages/di test
  • pnpm --dir packages/di build
  • pnpm --dir packages/testing typecheck
  • pnpm --dir packages/testing test
  • pnpm exec biome lint packages/di/src/container.ts packages/testing/src/module.ts packages/testing/src/module.test.ts
  • pnpm build
  • pnpm verify:release-readiness

Release impact

  • This PR has consumer-visible release impact and includes a changeset.
  • This PR has no consumer-visible release impact.

Changeset: .changeset/soft-pandas-guard.md records @fluojs/di as major and @fluojs/testing as patch.

Migration note: callers that used inspectResolutionState() as a mutable escape hatch must stop mutating returned registration/cache maps or normalized provider records. Framework-owned tooling should use the returned cacheOwner helpers for controlled cache adoption instead of writing to the maps directly. Ordinary application code should continue using has(...), resolve(...), and documented container APIs instead of the introspection seam.

Public export documentation

See docs/contracts/public-export-tsdoc-baseline.md for the repo-wide authoring baseline.

  • Changed public exports include a source-level summary.
  • Changed exported functions document matching @param / @returns tags where applicable.
  • Source @example blocks and README scenario examples still play complementary roles.

Behavioral contract

See docs/contracts/behavioral-contract-policy.md for full details.

  • No documented behavioral contracts were removed without migration notes.
  • New behavioral contracts are documented in the affected package README.
  • Intentional limitations are explicitly stated (not silently removed).
  • Runtime invariants are covered by regression tests.

Platform consistency governance (SSOT)

See docs/architecture/platform-consistency-design.md and docs/contracts/release-governance.md.

  • SSOT English/Korean mirror structure remains synchronized for changed governance docs.
  • If platform contract docs changed, companion updates include discoverability/docs index, tooling or CI enforcement, and regression-test evidence. (N/A: no platform contract docs changed.)
  • Any package README alignment/conformance claims are backed by createPlatformConformanceHarness(...) tests. (N/A: no platform conformance claim changed.)

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.

[audit][area:foundation] close DI request-scope lifecycle and introspection ownership gaps (priority:p1)

1 participant