Skip to content

fix(context): make injection strategy changes safely reversible - #644

Merged
yeongseon merged 2 commits into
mainfrom
fix/context-strategy-621
Oct 26, 2026
Merged

yeongseon merged 2 commits into
mainfrom
fix/context-strategy-621

Conversation

@yeongseon

Copy link
Copy Markdown
Owner

Summary

Make context-injection strategy changes explicit and reversible without uninstalling another library's record factory.

Changes

  • Preserve the eight-keyword API and default filter behavior.
  • Serialize factory ownership changes with setup; enabling removes exact package-owned context filters across registered loggers.
  • Switching back restores the previous factory only when our exact factory remains active; third-party replacements/wrappers cause a clear error before mutation.
  • Invalidate setup caches on strategy transitions; preserve host handlers, levels, user filter subclasses and formatter ownership.
  • Document quiescent reconfiguration, queue draining, bare-call semantics, standalone target recovery and the purpose of each remaining registry.

Validation

  • Characterization tests passed before the implementation: 958 passed, 4 skipped, 4 deselected, 13 warnings in 11.29s.
  • New regressions then failed for factory restoration and stale filters on another logger before the fix.
  • Python 3.11.15 make check-all and make build passed: 965 passed, 4 skipped, 4 deselected, 13 warnings in 10.88s; coverage 96.48%.
  • Coverage includes both directions, repeated setup, late host handlers, foreign predecessor preservation, foreign wrapper rejection, same-target local recovery, third-party logger output and concurrent invocation isolation in both modes.
  • No live Azure deployment was run. Repository mypy passed; local LSP rejects private-worktree paths.

Compatibility

True-to-False setup now restores the owned factory rather than leaving mixed injection active. Reconfigure only while logging is quiescent; keep passing use_record_factory=True for repeated creation-time snapshot setup. Tear down integrations wrapping our factory before switching. No public API is removed.

Related Issues

Closes #621

Merge authorized by the maintainer's explicit instruction, subject to exact-head required CI and resolved conversations.

@yeongseon

Copy link
Copy Markdown
Owner Author

Final review covers 9c4aa59. All five required contexts completed/success; branch CLEAN; no unresolved threads. Characterization preceded the two observed failing regressions. The fix restores only the exact owned factory, rejects foreign wrappers before mutation, and documents quiescent process-wide transitions and target recovery. Matrix, wheel and all SDK/local-host cells passed. Merge authorized by the maintainer’s explicit instruction.

@yeongseon
yeongseon merged commit 904ec8d into main Oct 26, 2026
26 checks passed
@yeongseon
yeongseon deleted the fix/context-strategy-621 branch October 26, 2026 14:47
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.

refactor(logging): make context-injection strategy lifetime explicit and reversible

1 participant