Skip to content

feat: add AhbContext dataclass for explicit dependency passing (w/o using it anywhere yet)#743

Merged
hf-kklein merged 4 commits into
mainfrom
feature/add-ahb-context
Apr 12, 2026
Merged

feat: add AhbContext dataclass for explicit dependency passing (w/o using it anywhere yet)#743
hf-kklein merged 4 commits into
mainfrom
feature/add-ahb-context

Conversation

@hf-kklein
Copy link
Copy Markdown
Contributor

Summary

  • Introduces AhbContext dataclass in src/ahbicht/content_evaluation/ahb_context.py — bundles rc_evaluator, fc_evaluator, hints_provider, package_resolver, and evaluatable_data into a single explicit context object
  • Two factory methods: from_content_evaluation_result (for pre-computed results like ahbicht-functions) and from_token_logic_provider (bridge for existing inject-based code)
  • This is PR 1 of a migration series to replace python-inject global DI with explicit parameter passing

Migration context

This is the first step in a multi-PR effort to:

  1. Separate parsing from evaluation
  2. Replace the global python-inject DI container with explicit AhbContext passing
  3. Make the library easier to set up and reason about

No action required by consumers yet — this is a pure addition. Subsequent PRs will thread AhbContext through evaluate_ahb_expression_tree and parse_expression_including_unresolved_subexpressions as an optional parameter (defaulting to None = old inject behavior).

For future consumers: how to use AhbContext

from ahbicht.content_evaluation.ahb_context import AhbContext

# Option 1: From pre-computed results (simplest)
ctx = AhbContext.from_content_evaluation_result(cer, EdifactFormat.UTILMD, EdifactFormatVersion.FV2210)

# Option 2: With custom evaluators
ctx = AhbContext(rc_evaluator=..., fc_evaluator=..., hints_provider=..., package_resolver=..., evaluatable_data=...)

# Option 3: Bridge from existing TokenLogicProvider
ctx = AhbContext.from_token_logic_provider(tlp, evaluatable_data)

Test plan

  • 5 new tests covering direct construction, CER factory, custom evaluatable_data, RC evaluator correctness, TLP bridge
  • All 529 existing tests still pass
  • pylint 10.00/10
  • mypy clean

🤖 Generated with Claude Code

hf-kklein and others added 3 commits April 12, 2026 10:43
Introduce AhbContext as the foundation for replacing the global
python-inject DI container with explicit parameter passing.

AhbContext bundles rc_evaluator, fc_evaluator, hints_provider,
package_resolver, and evaluatable_data into a single object that
will be threaded through parse and evaluate functions in subsequent PRs.

Includes two factory methods:
- from_content_evaluation_result: for pre-computed results (REST APIs)
- from_token_logic_provider: bridge for existing inject-based code

This is a pure addition — no existing behavior changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hf-kklein hf-kklein changed the title feat: add AhbContext dataclass for explicit dependency passing feat: add AhbContext dataclass for explicit dependency passing (w/o using it anywhere yet) Apr 12, 2026
@hf-kklein hf-kklein merged commit c37b2ea into main Apr 12, 2026
15 of 16 checks passed
@hf-kklein hf-kklein deleted the feature/add-ahb-context branch April 12, 2026 12:41
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