Skip to content

W2.B.2 — comprehension_gate validates executor consensus#51

Draft
TimothyVang wants to merge 2 commits into
feat/W2.B.1-nine-node-topologyfrom
feat/W2.B.2-comprehension-gate
Draft

W2.B.2 — comprehension_gate validates executor consensus#51
TimothyVang wants to merge 2 commits into
feat/W2.B.1-nine-node-topologyfrom
feat/W2.B.2-comprehension-gate

Conversation

@TimothyVang

Copy link
Copy Markdown
Owner

Summary

  • Replaces the W2.B.1 stub comprehension_gate_node with the real consensus + clarify sub-state per docs/ARCHITECTURE.md §2.
  • All 4 executor branches (vol_exec, hay_exec, pls_exec, mft_exec) must echo identical values for every consensus key (parsed_positive_hypothesis_ids, parsed_negative_hypothesis_ids, parsed_success_criteria_hash).
  • Disagreement spends one clarify iteration; MAX_CLARIFY_ITERATIONS=2 rounds of persistent disagreement -> comprehension_consensus=False + contested_hint naming the disagreeing key, route to replan_node.
  • Missing-executor (3-of-4 echo) and empty-echoes (all crashed) cases are treated as disagreement per ARCHITECTURE.md §1 empty-set rule (no silent free passes).
  • TDD: RED test(graph): RED — comprehension_gate consensus tests [W2.B.2] → GREEN feat(graph): comprehension_gate validates executor consensus [W2.B.2].

Test plan

  • pytest tests/graph/test_comprehension_gate.py -v — 9 passed.
  • pytest tests/graph/ -v — 18 passed (W2.B.1 + W2.B.2).
  • ruff check — clean.

Base

This PR targets feat/W2.B.1-nine-node-topology. Once the W2.B.1 PR merges to main, GitHub will rebase this PR's base accordingly.

TimothyVang added 2 commits May 2, 2026 08:38
Adds tests/graph/test_comprehension_gate.py asserting the gate's
behavior per BUILD_PLAN W2.B.2.a + ARCHITECTURE.md §2:

- 4-way agreement on (parsed_positive_hypothesis_ids,
  parsed_negative_hypothesis_ids, parsed_success_criteria_hash)
  -> comprehension_consensus=True -> ROUTE_GATE_PASS;
- mismatch -> clarify sub-state increments clarify_iterations;
- after MAX_CLARIFY_ITERATIONS=2 rounds with persistent mismatch
  -> consensus=False, contested_hint set, ROUTE_GATE_REPLAN;
- the contested_hint NAMES the disagreeing field
  (positive/negative/success_criteria_hash);
- missing executor (3-of-4 echo) is treated as disagreement per
  ARCHITECTURE.md §1 empty-set rule;
- empty echoes (all crashed) -> consensus=False, not silently True;
- distinct-branch counting: <4 distinct branches blocks consensus.

RED: ImportError on MAX_CLARIFY_ITERATIONS — the gate is currently a
W2.B.1 stub returning a fixed True. GREEN follows.
Replace the W2.B.1 stub `comprehension_gate_node` with the real
consensus + clarify sub-state per ARCHITECTURE.md §2.

Behaviour:
- Consensus check: all EXECUTOR_FANOUT_SIZE=4 distinct branches must
  echo identical values for every CONSENSUS_KEYS entry
  (parsed_positive_hypothesis_ids, parsed_negative_hypothesis_ids,
  parsed_success_criteria_hash). Lists are normalized to frozensets so
  emit-order doesn't break agreement.
- On disagreement, the gate spends one clarify_iteration and re-prompts
  (within the same node — keeps total node count at 9).
- After MAX_CLARIFY_ITERATIONS=2 rounds with persistent disagreement,
  the gate concedes: emits comprehension_consensus=False plus a
  contested_hint NAMING the disagreeing CONSENSUS_KEY so replan_node
  has a concrete remediation target.
- Missing-executor (3-of-4 echo) and empty-echoes (all crashed) cases
  are treated as disagreement per ARCHITECTURE.md §1 empty-set rule.

Pure consensus logic — no LLM, no microsandbox, no external service —
so the test surface runs in CI without dependencies.

Tests: 9 new comprehension_gate tests + 9 W2.B.1 topology tests = 18 PASS.
Ruff: clean.
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