Phase 5: Guard context alignment — online prefilter parity#551
Merged
Muizzkolapo merged 4 commits intoMay 17, 2026
Merged
Conversation
Proves the context divergence bug: prefilter_by_guard passes context=eval_item (record content only), while TaskPreparer.prepare builds full field_context with source, version, workflow namespaces and promoted output_fields. Guards referencing source.name, version.i, or promoted output_fields produce different decisions in online vs batch — 5 tests fail.
Extract guard context construction into processing/guard_context.py as the single source of truth for both batch and online paths. TaskPreparer._load_full_context now delegates to build_guard_context, ensuring the output_field promotion and source resolution logic lives in one place. This prevents the two paths from diverging. Update test that patched the old logger location.
prefilter_by_guard now accepts optional pipeline context parameters (agent_indices, source_data, version_context, workflow_metadata, dependency_configs). When provided, it builds full field_context via build_guard_context — identical to what TaskPreparer.prepare() uses. Both _guard_filter and _guard_filter_file_mode in unified.py pass the ProcessingContext fields through, so online guards now see the same source, version, workflow namespaces and promoted output_fields that batch guards see. When no pipeline context is provided, prefilter falls back to eval_item (backward-compatible for callers outside unified.py). All 9 Phase 5 parity tests pass. 6847 existing tests pass.
8747da2
into
integration/batch-online-unification
1 check passed
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
build_guard_contexthelper (processing/guard_context.py) that builds identical field_context for both online prefilter and batch prepare guard evaluationprefilter_by_guardto accept optional pipeline context params (agent_indices, source_data, version_context, workflow_metadata, dependency_configs) and usebuild_guard_contextwhen availableTaskPreparer._load_full_contextto delegate to the same shared helper, preventing drift_guard_filterand_guard_filter_file_modeinunified.pyto pass ProcessingContext fields throughCloses the "works in batch, fails online" guard class: guards referencing source namespace, version namespace, workflow metadata, or promoted output_fields now produce identical decisions in both execution modes.
Verification
ruff format --checkandruff checkcleanGUARD_SKIPPEDinCASCADE_BLOCKING_STATES(U-1.4 constraint)