Skip to content

Phase 5: Guard context alignment — online prefilter parity#551

Merged
Muizzkolapo merged 4 commits into
integration/batch-online-unificationfrom
unify/phase-5-guard-context-alignment
May 17, 2026
Merged

Phase 5: Guard context alignment — online prefilter parity#551
Muizzkolapo merged 4 commits into
integration/batch-online-unificationfrom
unify/phase-5-guard-context-alignment

Conversation

@Muizzkolapo
Copy link
Copy Markdown
Owner

Summary

  • Extract shared build_guard_context helper (processing/guard_context.py) that builds identical field_context for both online prefilter and batch prepare guard evaluation
  • Wire prefilter_by_guard to accept optional pipeline context params (agent_indices, source_data, version_context, workflow_metadata, dependency_configs) and use build_guard_context when available
  • Refactor TaskPreparer._load_full_context to delegate to the same shared helper, preventing drift
  • Wire both _guard_filter and _guard_filter_file_mode in unified.py to pass ProcessingContext fields through

Closes 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

  • 9 new Phase 5 parity tests pass (source, version, output_field promotion, code_centered_quiz)
  • 6847 existing tests pass (2 pre-existing failures excluded: ollama trailing comma, json parsing)
  • ruff format --check and ruff check clean
  • No changes to batch path behavior (TaskPreparer.prepare still produces identical output)
  • No GUARD_SKIPPED in CASCADE_BLOCKING_STATES (U-1.4 constraint)

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.
@Muizzkolapo Muizzkolapo merged commit 8747da2 into integration/batch-online-unification May 17, 2026
1 check passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant