Skip to content

Conversation

@colombod
Copy link
Contributor

Summary

Expands the anti-patterns section in DESIGN_PHILOSOPHY.md with explicit guidance about accessing private state via getattr(obj, '_private', ...).

Motivation

This PR was motivated by microsoft/amplifier-app-cli#70 which demonstrates a "fix" that reaches into private internal state instead of using public APIs:

# The anti-pattern from PR #70
bundle_resolver = getattr(resolver, "_bundle", resolver)  # Unwrap layer 1
activator = getattr(bundle_resolver, "_activator", None)   # Unwrap layer 2

The comment "Pattern from session_spawner.py" shows this anti-pattern is spreading across the codebase, making it important to document why this is wrong.

What's Added

New subsection "Accessing Private State (Critical Anti-Pattern)" under Module Development anti-patterns:

  • Why this pattern is dangerous (changes without warning, multiplied fragility)
  • Code example showing wrong vs right approach
  • Guidance on when internal access seems needed
  • Litmus test for detecting protocol violations

Design Philosophy Alignment

This aligns with existing principles:

  • "Depending on kernel internals (use protocols only)" - now with explicit examples
  • "Mechanism, Not Policy" - private state is implementation detail, not contract
  • "Bricks & Studs" - interfaces (studs) should be used, not internal brick structure

Related


🤖 Generated with Amplifier

Co-Authored-By: Amplifier 240397093+microsoft-amplifier@users.noreply.github.com

@colombod colombod force-pushed the docs/private-state-antipattern branch from 607fe3b to 0f23601 Compare January 28, 2026 19:26
Add bullet to 'In Module Development' anti-patterns about bypassing
public interfaces to access internal state.

Motivated by microsoft/amplifier-app-cli#70.

🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier)

Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
@colombod colombod force-pushed the docs/private-state-antipattern branch from 0f23601 to 0faf27e Compare January 28, 2026 19:28
@colombod
Copy link
Contributor Author

Closing in favor of adding this to IMPLEMENTATION_PHILOSOPHY.md in amplifier-foundation instead - that's the right place for development-time guidance.

@colombod colombod closed this Jan 28, 2026
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