Angshuman28 commited on
Commit
736da4a
Β·
verified Β·
1 Parent(s): 53adefa

Upload folder using huggingface_hub

Browse files
docs/CORTEX_ARCHITECTURE.md CHANGED
@@ -192,11 +192,21 @@ class RouterStep(BaseModel):
192
  metacognition_state: MetacognitionState
193
  tokens_spent: int
194
  subagent_report: Optional[SubagentReport] = None # populated when routing_action.kind == "call_subagent"
 
195
  ```
196
 
197
  **Rationale:** Per cortex/CLAUDE.md "Logging contract", the training-data
198
  row IS one router step. This schema makes it easy to dump a full
199
- trajectory as `List[RouterStep]` without bespoke serialisation.
 
 
 
 
 
 
 
 
 
200
 
201
  #### A4. `Trajectory` (Session 13 β€” referenced by training/* and inference.py)
202
 
@@ -268,9 +278,21 @@ while True:
268
  - **Forward only**: Divergence β†’ Challenge β†’ Narrowing β†’ Convergence. No
269
  forward-skipping (cortex/CLAUDE.md "Phase machine invariants").
270
  - **Backward re-entry on dissent**: if `preserve_dissent` was emitted *and*
271
- `metacog_state.preserved_dissent_count` increased above a tracked
272
- threshold, the router may emit `switch_phase(Challenge)` to re-open
273
- challenge. This is the only allowed backward transition.
 
 
 
 
 
 
 
 
 
 
 
 
274
  - **Round increment**: every time `phase` returns to Divergence (or
275
  re-enters Challenge from Convergence/Narrowing via a backtrack), the
276
  Council Executive checks `deliberation_rounds_used`. If it's already 2,
@@ -294,6 +316,28 @@ while True:
294
  the failing brain's recommendation is treated as `top_action = NoOp()`
295
  with `top_confidence = 0.0`; the round continues with the other two.
296
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
  ---
298
 
299
  ## Β§4 β€” Hard cap accounting and preserved-dissent tracking
@@ -629,7 +673,7 @@ Decisions are grouped by layer. Each entry: **decision** / **rationale** /
629
 
630
  5. **Subagent output validated via Pydantic `TypeAdapter[<role-specific-type>]`.** / Already the pattern in `parse_action` (B1); reusable. / Considered hand-rolled JSON parsing; rejected β€” Pydantic gives discriminated-union safety free.
631
 
632
- 6. **Empty `SubagentReport` on parse / call failure: `confidence=0.0, evidence=[]`** for any of the three subagent types (with role-specific other fields zeroed/empty). / Honest "no signal" state; downstream r_proto naturally penalizes. / Considered raising the exception; rejected β€” would break the per-brain isolation contract.
633
 
634
  7. **Subagent caller_id format: `cortex:<brain>:<role>:t<tick>:r<round>:s<step_idx>`.** / Mirrors B2's `b2:t<tick>:p<n>:<role>` pattern. / Considered a flat `cortex:<step_idx>` form; rejected β€” losing the per-brain breakdown loses critical training analytics.
635
 
@@ -637,7 +681,7 @@ Decisions are grouped by layer. Each entry: **decision** / **rationale** /
637
 
638
  ### Lenses (Session 10)
639
 
640
- 9. **Three lenses: epidemiology, logistics, governance. Each is a function `lens_for(brain, obs) -> BrainLensedObservation`.** / Matches the 3 brains. / V2 brains (Communications, Equity) have stub lens entries returning `BrainLensedObservation` with the full obs; future sessions add real ones.
641
 
642
  10. **Epidemiology derived features: `r_effective_estimate, worst_region_infection, transmission_rate_trend`.** / These are exactly the signals an epi-savvy human would compute from telemetry. / Considered raw telemetry only (no derived features); rejected β€” forces every WM call to redo the same computations.
643
 
@@ -673,17 +717,17 @@ Decisions are grouped by layer. Each entry: **decision** / **rationale** /
673
 
674
  24. **Aggregation rule for the 3 `BrainRecommendation`s: weighted vote on `top_action.kind` first, then on parameters within the winning kind.** / Two-level vote keeps semantically-similar actions together. / Considered exact-match-only; rejected β€” would force Cortex to flip-flop on minor parameter differences.
675
 
676
- 25. **Vote weight per brain: `top_confidence Γ— evidence_count`.** / Rewards confident, well-evidenced brains. / Considered uniform weights; rejected β€” would erase brain-level differences.
677
 
678
  26. **Tie-breaking: deterministic ordering `epidemiology > logistics > governance`.** / Required for eval determinism. / Considered random; rejected β€” breaks the eval-mode determinism contract.
679
 
680
- 27. **Cross-brain challenge selection: when `request_challenge` fires, the *challenger_brain*'s Critic runs against the *target_brain*'s top plan.** / Matches design Β§10 worked example. / Considered pairwise challenge (both brains' Critics); rejected β€” exceeds the 1-challenge cap.
681
 
682
  28. **Phase advancement triggers** (Session 13's deterministic router; Session 15 learns these):
683
  - Divergence β†’ Challenge: `inter_brain_agreement < 0.4` AND `round 1 complete`.
684
  - Challenge β†’ Narrowing: challenge resolved OR cap hit.
685
  - Narrowing β†’ Convergence: top candidate stable across last router step OR `urgency > 0.7` OR `budget_remaining_frac < 0.2`.
686
- / These thresholds are the deterministic-router defaults; trainable router learns its own. / Other thresholds considered; locked here for Session 13's reproducibility.
687
 
688
  29. **Forced convergence on round 2 cap: emit current top-ranked action; if no candidate, emit `parse_failure_marker()`.** / Matches B2's pattern. / Considered emitting `NoOp()` directly; rejected β€” `parse_failure_marker` correctly fires the r_policy=0 penalty.
689
 
@@ -701,7 +745,7 @@ Decisions are grouped by layer. Each entry: **decision** / **rationale** /
701
 
702
  35. **`collapse_suspicion`: 1.0 if all 3 brains' `top_action` is bytewise-equal AND all 3 evidence lists are length 0; else 0.0.** / Catches the "all said NoOp with no reasoning" failure. / Considered a graded score; rejected β€” this is the binary signal eval cares about.
703
 
704
- 36. **`urgency`: `1.0 - ticks_remaining / max_ticks` clipped + `worst_region_infection_estimate Γ— 0.5`, clamped to [0, 1].** / Both time pressure and crisis severity. / Considered ticks-only; rejected β€” task-difficulty differences vanish.
705
 
706
  37. **`novelty_yield_last_round`: only computed in round 2; round 1 always returns 0.0.** / Eval-only signal per design Β§7.4.3 line 404. / N/A.
707
 
@@ -709,10 +753,11 @@ Decisions are grouped by layer. Each entry: **decision** / **rationale** /
709
 
710
  38. **Session 13 deterministic router decision table** (binding for B3 baseline):
711
  - Round 1, Divergence, no recommendations yet: `call_subagent(epi, world_modeler)`, then `(epi, planner)`, then `(epi, critic)`, then logistics, then governance β€” fixed brain order.
712
- - End of round 1, agreement < 0.4: `switch_phase(Challenge)` β†’ `request_challenge(challenger=logistics, target=epidemiology)`.
 
713
  - End of round 2 OR agreement β‰₯ 0.7: `switch_phase(Convergence)` β†’ `emit_outer_action(council_top)`.
714
  - Budget < 20% remaining: `emit_outer_action` immediately.
715
- / Reproduces design Β§10 worked example. / N/A.
716
 
717
  39. **Session 15 trainable router: Option B (small MLP head over 24-dim featurized state, discrete output over top-50 most-common (kind, brain, subagent) tuples).** / Per design Β§22; Colab-compatible. / Option A (LoRA) is the stretch.
718
 
@@ -764,26 +809,50 @@ Decisions are grouped by layer. Each entry: **decision** / **rationale** /
764
 
765
  60. **All MetacognitionState fields use `float ∈ [0, 1]` except `tick`, `round`, `preserved_dissent_count`, `challenge_used_this_tick`.** / Already locked in `cortex/schemas.py`. / N/A.
766
 
767
- ### Decisions flagged for human review (NOT auto-resolved)
768
-
769
- These need explicit βœ… / ❌ before Session 9 starts:
770
-
771
- - **D-FR-1.** Should Sessions 13's deterministic router emit
772
- `request_challenge` only on `inter_brain_agreement < 0.4`, or also on
773
- `inter_brain_agreement ∈ [0.4, 0.7] AND round == 1`? / The latter is
774
- more aggressive but uses the challenge cap more often (matched-
775
- compute story may shift).
776
- - **D-FR-2.** Should the Council Executive's vote weight use
777
- `top_confidence Γ— evidence_count` (Decision 25) or
778
- `top_confidence Γ— evidence_count Γ— (1 - uncertainty)`? / The latter
779
- punishes confidently-wrong brains harder.
780
- - **D-FR-3.** Should `parse_failure_marker()` fire on any subagent parse
781
- failure, or only on the brain's *Brain Executive* declaring "all
782
- subagents empty"? / The current proposal (Decision 6 + 42) is the
783
- latter; a more aggressive policy would fire it earlier.
784
- - **D-FR-4.** Should `MetacognitionState.urgency` weight the worst-region
785
- infection at 0.5 (Decision 36) or 1.0? / Higher weight = router
786
- converges faster on hard tasks.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
787
 
788
  ---
789
 
@@ -873,17 +942,25 @@ Session 15 (out of Phase A scope) (Trainable router)
873
 
874
  ### Word count
875
 
876
- β‰ˆ 6,750 words. Within the 5,000–8,000 target.
 
 
 
 
 
 
877
 
878
  ### Sections completed (10/10)
879
 
880
- Β§1 Data flow / Β§2 Schemas / Β§3 Phase machine / Β§4 Hard caps + dissent /
881
- Β§5 Token budget / Β§6 Routing policy / Β§7 Failure modes / Β§8 Test
882
- strategy / Β§9 Pre-approved decisions (60 entries) / Β§10 Sequencing.
 
 
883
 
884
  ### Decisions auto-resolved (rationales recorded inline in Β§9)
885
 
886
- 60 modeling decisions, grouped by layer:
887
  - 8 subagent decisions
888
  - 6 lens decisions
889
  - 7 brain executive decisions
@@ -893,39 +970,43 @@ strategy / Β§9 Pre-approved decisions (60 entries) / Β§10 Sequencing.
893
  - 3 failure / fallback decisions
894
  - 4 testing decisions
895
  - 12 tooling / V2-deferral decisions
 
 
 
 
 
896
 
897
- ### Decisions flagged for human review (4)
898
-
899
- - **D-FR-1.** Aggressive vs. conservative challenge-trigger threshold
900
- for Session 13's deterministic router.
901
- - **D-FR-2.** Whether the council's vote weight should include
902
- `(1 - uncertainty)` as an additional factor.
903
- - **D-FR-3.** Whether `parse_failure_marker` should fire on any
904
- subagent parse failure, or only on full-brain "all subagents empty".
905
- - **D-FR-4.** `MetacognitionState.urgency` weight on worst-region
906
- infection (0.5 vs 1.0).
907
-
908
- ### Open questions before Session 9 starts
909
-
910
- - **OQ-1.** What temperature value > 0 should training rollouts use?
911
- cortex/CLAUDE.md says "higher temperature during training rollouts"
912
- but doesn't pin a number. Suggest `0.7` based on common GRPO setups;
913
- needs Session 15 acknowledgement.
914
- - **OQ-2.** Should `PerceptionReport.salient_signals` be free-form
915
- strings or constrained to a per-brain enum? The schema currently has
916
- `List[str]`; constraining would make tests stricter but Lens output
917
- more rigid.
918
- - **OQ-3.** When the trainable router (Session 15) crashes mid-tick
919
- and falls back to deterministic (Β§7), should the deterministic
920
- router's choices be logged as `RouterStep`s for training data, or
921
- marked as off-policy and excluded? GRPO advantage computation differs
922
- in each case.
 
 
923
 
924
  ### What is NOT in this document
925
 
926
  - No Python code (per the no-code constraint).
927
- - No commit. The file is written but not staged. Run
928
- `git add docs/CORTEX_ARCHITECTURE.md && git commit -m "docs(cortex):
929
- add Phase A architecture contract"` if/when ready.
930
  - No Session 14+ details (training reward composition, eval harness,
931
  HF Spaces deploy). Phase A intentionally bounds at Session 13.
 
192
  metacognition_state: MetacognitionState
193
  tokens_spent: int
194
  subagent_report: Optional[SubagentReport] = None # populated when routing_action.kind == "call_subagent"
195
+ policy_kind: Literal["trainable", "deterministic_fallback"] = "trainable" # which policy emitted this step
196
  ```
197
 
198
  **Rationale:** Per cortex/CLAUDE.md "Logging contract", the training-data
199
  row IS one router step. This schema makes it easy to dump a full
200
+ trajectory as `List[RouterStep]` without bespoke serialisation. The
201
+ `policy_kind` field (OQ-3 resolution) tags which policy emitted the
202
+ step: `"trainable"` for the Session-15 learned router, `"deterministic_fallback"`
203
+ for the Session-13 router used both as B3 baseline AND as the crash
204
+ fallback when the trainable router raises mid-tick (see Β§7 metacognition
205
+ layer). GRPO advantage computation filters to `policy_kind == "trainable"`
206
+ only β€” fallback steps are off-policy and excluded from the gradient.
207
+ Default is `"trainable"` so B3 round-tripping does not need to set the
208
+ field; B3 is a baseline, not training data, so the default value is
209
+ inert for B3 trajectories.
210
 
211
  #### A4. `Trajectory` (Session 13 β€” referenced by training/* and inference.py)
212
 
 
278
  - **Forward only**: Divergence β†’ Challenge β†’ Narrowing β†’ Convergence. No
279
  forward-skipping (cortex/CLAUDE.md "Phase machine invariants").
280
  - **Backward re-entry on dissent**: if `preserve_dissent` was emitted *and*
281
+ `metacog_state.preserved_dissent_count >= 2`, the router may emit
282
+ `switch_phase(Challenge)` to re-open challenge. This is the only
283
+ allowed backward transition. The `>= 2` threshold (Item A resolution)
284
+ reflects "two preserved dissents = real minority views surfaced; a
285
+ single one is noise" β€” re-opening challenge on a single preserved
286
+ dissent would burn the cross-brain-challenge cap on what may be a
287
+ one-off objection.
288
+ - **Round-2 entry trigger** (Item C resolution): the router enters
289
+ round 2 ONLY by emitting an explicit `switch_phase(Divergence)`
290
+ routing action. Council Executive forbids implicit round increment
291
+ (e.g. silently bumping `round = 2` after Convergence-without-emit).
292
+ Rationale: every round boundary is an explicit policy decision,
293
+ which keeps the Session-15 router's training signal clean β€” the
294
+ trainable router learns "when to spend a second round" as a
295
+ first-class action choice rather than as an emergent side-effect.
296
  - **Round increment**: every time `phase` returns to Divergence (or
297
  re-enters Challenge from Convergence/Narrowing via a backtrack), the
298
  Council Executive checks `deliberation_rounds_used`. If it's already 2,
 
316
  the failing brain's recommendation is treated as `top_action = NoOp()`
317
  with `top_confidence = 0.0`; the round continues with the other two.
318
 
319
+ ### Phase-to-protocol mapping (Item F resolution)
320
+
321
+ The 5-step anti-hivemind protocol (cortex/CLAUDE.md, Β§8.1 of design doc)
322
+ maps onto the 4-phase machine as follows. This pin lets
323
+ `tests/test_cortex_protocol_invariants.py` assert the exact protocol
324
+ step exercised in each phase.
325
+
326
+ | Anti-hivemind step | Phase |
327
+ |---|---|
328
+ | 1. Independent reasoning (private first pass) | Divergence |
329
+ | 2. Cross-brain critique (typed evidence disclosure + targeted challenge entry) | Challenge phase entry |
330
+ | 3. Counter-recommendation (challenge resolved or accepted) | Challenge phase end |
331
+ | 4. Anonymized comparison | **Deferred V2 per Decision 56** β€” not implemented in MVP |
332
+ | 5. Final aggregation with preserved dissent | Narrowing + Convergence |
333
+
334
+ The Session-12 protocol-invariant test asserts that for any `Council.step`
335
+ trace, every phase-entry `RouterStep` is paired with exactly the protocol
336
+ step listed above (or a logged short-circuit reason β€” e.g. budget
337
+ exhausted, brain failure, override). Step 4 is asserted as
338
+ **not-fired** in MVP; if it ever fires, the test treats that as a
339
+ forward-leak from a V2 branch into MVP and fails closed.
340
+
341
  ---
342
 
343
  ## Β§4 β€” Hard cap accounting and preserved-dissent tracking
 
673
 
674
  5. **Subagent output validated via Pydantic `TypeAdapter[<role-specific-type>]`.** / Already the pattern in `parse_action` (B1); reusable. / Considered hand-rolled JSON parsing; rejected β€” Pydantic gives discriminated-union safety free.
675
 
676
+ 6. **Empty `SubagentReport` on parse / call failure: `confidence=0.0, evidence=[]`** for any of the three subagent types (with role-specific other fields zeroed/empty). / Honest "no signal" state; downstream r_proto naturally penalizes. / Considered raising the exception; rejected β€” would break the per-brain isolation contract. **(D-FR-3 reinforcement)** A single subagent's empty fallback does NOT trigger `parse_failure_marker` β€” that fires only on full-brain emptiness (Brain Executive sees `top_confidence == 0` from all 3 subagents); see Decision 42.
677
 
678
  7. **Subagent caller_id format: `cortex:<brain>:<role>:t<tick>:r<round>:s<step_idx>`.** / Mirrors B2's `b2:t<tick>:p<n>:<role>` pattern. / Considered a flat `cortex:<step_idx>` form; rejected β€” losing the per-brain breakdown loses critical training analytics.
679
 
 
681
 
682
  ### Lenses (Session 10)
683
 
684
+ 9. **Three lenses: epidemiology, logistics, governance. Each is a function `lens_for(brain, obs) -> BrainLensedObservation`.** / Matches the 3 brains. / **(Item E resolution)** V2 brains (Communications, Equity) deferred entirely per Decision 56 β€” no MVP stub lens functions. `lens_for(brain, obs)` raises `KeyError` on `brain ∈ {'communications', 'equity'}`. Rationale: stubs returning the raw obs would silently let a V2-leaked code path "work", masking the boundary; raising is the loud-fail behaviour V2 deferral contracts demand.
685
 
686
  10. **Epidemiology derived features: `r_effective_estimate, worst_region_infection, transmission_rate_trend`.** / These are exactly the signals an epi-savvy human would compute from telemetry. / Considered raw telemetry only (no derived features); rejected β€” forces every WM call to redo the same computations.
687
 
 
717
 
718
  24. **Aggregation rule for the 3 `BrainRecommendation`s: weighted vote on `top_action.kind` first, then on parameters within the winning kind.** / Two-level vote keeps semantically-similar actions together. / Considered exact-match-only; rejected β€” would force Cortex to flip-flop on minor parameter differences.
719
 
720
+ 25. **Vote weight per brain: `top_confidence Γ— evidence_count`.** / Rewards confident, well-evidenced brains. / Considered uniform weights; rejected β€” would erase brain-level differences. **(D-FR-2 resolution)** Do NOT multiply by `(1 - uncertainty)` here β€” Decision 16 already bakes `(1 - uncertainty)` into `top_confidence` via the multiplicative `confidence Γ— (1 - uncertainty)` rule. Adding it again at the council layer would double-count uncertainty and over-penalise the most-uncertain brain. Cross-reference Decision 16 when reviewing this in future sessions.
721
 
722
  26. **Tie-breaking: deterministic ordering `epidemiology > logistics > governance`.** / Required for eval determinism. / Considered random; rejected β€” breaks the eval-mode determinism contract.
723
 
724
+ 27. **Cross-brain challenge selection: when `request_challenge` fires, the *challenger_brain*'s Critic runs against the *target_brain*'s top plan.** / Matches design Β§10 worked example. / Considered pairwise challenge (both brains' Critics); rejected β€” exceeds the 1-challenge cap. **(Item B resolution)** Cross-brain Critic USR field includes BOTH the target's `PerceptionReport` AND the challenger's `PerceptionReport` (β‰ˆ 200 extra tokens / cross-brain challenge β€” affordable within `TICK_BUDGET=6000`). Rationale: a logistics Critic challenging an epi plan needs the epi-lens view of the data (otherwise the critique is uninformed) plus its own logistics-lens view (otherwise the challenge has no domain leverage). Single-perception Critic was considered and rejected β€” would force the Critic to "guess" what the target brain saw.
725
 
726
  28. **Phase advancement triggers** (Session 13's deterministic router; Session 15 learns these):
727
  - Divergence β†’ Challenge: `inter_brain_agreement < 0.4` AND `round 1 complete`.
728
  - Challenge β†’ Narrowing: challenge resolved OR cap hit.
729
  - Narrowing β†’ Convergence: top candidate stable across last router step OR `urgency > 0.7` OR `budget_remaining_frac < 0.2`.
730
+ / These thresholds are the deterministic-router defaults; trainable router learns its own. / Other thresholds considered; locked here for Session 13's reproducibility. **(D-FR-1 resolution)** Conservative-only: `< 0.4` is the *single* threshold for `request_challenge` firing. The aggressive variant β€” also firing on `agreement ∈ [0.4, 0.7] AND round == 1` β€” was rejected. Reasoning: the challenge cap is 1/tick, so aggressive triggering buys *earlier* challenges, not *more* challenges. Challenging moderate disagreement (the [0.4, 0.7] band) misallocates the cap; high agreement is consensus and must not be challenged at all. Aligns with the anti-hivemind story β€” challenge real dissent, not moderate disagreement.
731
 
732
  29. **Forced convergence on round 2 cap: emit current top-ranked action; if no candidate, emit `parse_failure_marker()`.** / Matches B2's pattern. / Considered emitting `NoOp()` directly; rejected β€” `parse_failure_marker` correctly fires the r_policy=0 penalty.
733
 
 
745
 
746
  35. **`collapse_suspicion`: 1.0 if all 3 brains' `top_action` is bytewise-equal AND all 3 evidence lists are length 0; else 0.0.** / Catches the "all said NoOp with no reasoning" failure. / Considered a graded score; rejected β€” this is the binary signal eval cares about.
747
 
748
+ 36. **`urgency`: `1.0 - ticks_remaining / max_ticks` clipped + `worst_region_infection_estimate Γ— 0.5`, clamped to [0, 1].** / Both time pressure and crisis severity. / Considered ticks-only; rejected β€” task-difficulty differences vanish. **(D-FR-4 resolution)** Multiplier confirmed at `0.5`. The alternative β€” `Γ— 1.0` β€” was rejected: a 1.0 weight would force premature convergence on `outbreak_hard` precisely when anti-hivemind reasoning matters most. Hard tasks need *more* deliberation, not faster convergence. The 0.5 weight lets infection severity nudge urgency without dominating it.
749
 
750
  37. **`novelty_yield_last_round`: only computed in round 2; round 1 always returns 0.0.** / Eval-only signal per design Β§7.4.3 line 404. / N/A.
751
 
 
753
 
754
  38. **Session 13 deterministic router decision table** (binding for B3 baseline):
755
  - Round 1, Divergence, no recommendations yet: `call_subagent(epi, world_modeler)`, then `(epi, planner)`, then `(epi, critic)`, then logistics, then governance β€” fixed brain order.
756
+ - End of round 1, agreement < 0.4: `switch_phase(Challenge)` β†’ `request_challenge(challenger, target)` where **`challenger = brain with min(top_confidence)`** and **`target = brain with max(top_confidence)`**, ties broken by Decision 26's deterministic ordering (`epidemiology > logistics > governance`).
757
+ - **All-equal-confidences edge case**: when `min(top_confidence) == max(top_confidence)` across all three brains, do NOT fire `request_challenge` at all. Skip the Challenge phase and `switch_phase(Narrowing)` directly. Cross-brain challenge requires productive asymmetry; identical confidences provide none β€” Decision-26 tie-break would otherwise collapse to `challenger == target == epidemiology`, violating the cross-brain contract. The 1-challenge cap is preserved (unspent), and the council still has the dissent-preservation channel for surfacing minority recommendations.
758
  - End of round 2 OR agreement β‰₯ 0.7: `switch_phase(Convergence)` β†’ `emit_outer_action(council_top)`.
759
  - Budget < 20% remaining: `emit_outer_action` immediately.
760
+ / Reproduces design Β§10 worked example. / **(Decision-38 inconsistency fix)** The earlier draft hardcoded `challenger=logistics, target=epidemiology` without justification. The dynamic pair lets the *most-uncertain* brain push back on the *most-confident*, which is where anti-hivemind correction has highest expected value: a low-confidence brain challenging a high-confidence one is exactly the configuration where dissent could productively flip the council's decision. Hardcoded pair was rejected because (a) it presupposes which domain is "always right to be challenged", which the design doc does not assert, and (b) it defeats the point of the metacognition signal feeding the router. The all-equal-confidences edge case is handled by short-circuiting to Narrowing rather than firing a same-brain self-challenge.
761
 
762
  39. **Session 15 trainable router: Option B (small MLP head over 24-dim featurized state, discrete output over top-50 most-common (kind, brain, subagent) tuples).** / Per design Β§22; Colab-compatible. / Option A (LoRA) is the stretch.
763
 
 
809
 
810
  60. **All MetacognitionState fields use `float ∈ [0, 1]` except `tick`, `round`, `preserved_dissent_count`, `challenge_used_this_tick`.** / Already locked in `cortex/schemas.py`. / N/A.
811
 
812
+ ### Phase A review-pass additions (Sessions 9–13 binding)
813
+
814
+ These decisions land during the Phase A review pass (April 2026); each
815
+ is locked to the same standard as Decisions 1–60.
816
+
817
+ 61. **Round-2 entry mechanism** (Item C): the router enters round 2 ONLY by emitting an explicit `switch_phase(Divergence)` routing action. Council Executive forbids implicit round increment. / Every round boundary becomes a first-class policy decision; the Session-15 trainable router learns "when to spend a second round" as an explicit action choice rather than an emergent side-effect β€” cleaner gradient signal. / Considered implicit round-bump on Convergence-without-emit; rejected β€” would couple round increment to phase state and obscure the router's training signal. (Cross-reference Β§3 transition rules.)
818
+
819
+ 62. **Round-2 `prior_belief` encoding when round 1 produced nothing** (Item D): when round 1 produced no useful `BeliefState` (parse failure, empty subagent fallback, or LLM-call exception), round-2 `SubagentInput.prior_belief` is an EMPTY `BeliefState(brain=<X>, latent_estimates={}, hypotheses=[], uncertainty=1.0, reducible_by_more_thought=False, evidence=[])`, NOT `None`. / Different prompt signals: `None` tells the WorldModeler "round 1 has not happened, no history to revise"; an empty `BeliefState` tells it "round 1 happened, produced nothing β€” start clean but acknowledge the failed pass". Conflating the two would mask the failure mode in the trajectory log. / Considered using `None` for both; rejected β€” collapses two distinct epistemic states into one.
820
+
821
+ 63. **`PerceptionReport.salient_signals` cap** (OQ-2 resolution): `salient_signals` is `List[str]` with **at most 5 entries** per report. Pydantic validator enforces. / Cap prevents the LLM (in V2 lens-extension experiments) from emitting a paragraph as a "signal"; tests assert content not schema. / Considered a per-brain enum; rejected β€” over-rigid for early MVP iteration where lens features are still being tuned.
822
+
823
+ 64. **Training-rollout temperature** (OQ-1 resolution): deferred to Session 15. Phase A does not pin a numeric value. `cortex.llm_client.LLMClient.chat(..., temperature: float = 0.0)` already exposes the parameter; Session 15 trainer reads its rollout temperature from the GRPO config and passes it through. / Right session for this decision is Session 15, where the trainer will run early experiments and pick a value based on observed exploration. / Considered pinning `0.7` (common GRPO default); rejected β€” premature; locks a hyperparameter before any training data exists.
824
+
825
+ 65. **`RouterStep.policy_kind` GRPO advantage filter** (OQ-3 resolution): when the Session-15 trainable router crashes mid-tick and Council falls back to the deterministic router (per Β§7 metacognition layer), the deterministic-router steps that close the tick are tagged `policy_kind="deterministic_fallback"`. GRPO advantage computation filters to `policy_kind == "trainable"` ONLY β€” fallback steps are off-policy with respect to the gradient. B3 baseline runs are unaffected: every B3 RouterStep gets the default `policy_kind="trainable"`, but B3 trajectories are not training data so the field is inert for B3. / Cleanest split: keep all router steps on the trajectory (so trainer can still measure failure rate, fallback-tick reward, etc.) but exclude fallback steps from the policy gradient. / Considered dropping fallback steps entirely from the trajectory; rejected β€” loses observability into how often the trainable router crashes and what the deterministic fallback does instead. (Cross-reference Β§2 A3 schema and Β§7 metacognition layer.)
826
+
827
+ ### Decisions resolved during Phase A review pass (April 2026)
828
+
829
+ All four D-FR items below were resolved in the review pass and folded
830
+ into the relevant decision entries above. Listed here for trace-
831
+ ability; the binding text now lives on the referenced decisions.
832
+
833
+ - **D-FR-1 β†’ resolved.** Conservative threshold only (`inter_brain_agreement < 0.4`). Aggressive variant rejected. β†’ Decision 28 updated.
834
+ - **D-FR-2 β†’ resolved.** Vote weight stays `top_confidence Γ— evidence_count`; do NOT add `(1 - uncertainty)` factor (already in Decision 16's `top_confidence`). β†’ Decision 25 updated.
835
+ - **D-FR-3 β†’ resolved.** `parse_failure_marker` fires only on full-brain emptiness (status quo of Decisions 6 + 42). Single-subagent failures use 1-retry + empty-report fallback. β†’ Decision 6 updated.
836
+ - **D-FR-4 β†’ resolved.** `urgency` keeps `worst_region_infection Γ— 0.5`. The 1.0 weight was rejected β€” would force premature convergence on `outbreak_hard`. β†’ Decision 36 updated.
837
+
838
+ ### Open questions resolved during Phase A review pass
839
+
840
+ - **OQ-1 β†’ resolved.** Training-rollout temperature deferred to Session 15. β†’ Decision 64 added.
841
+ - **OQ-2 β†’ resolved.** `salient_signals` is free-form `List[str]` capped at 5. β†’ Decision 63 added.
842
+ - **OQ-3 β†’ resolved.** Trainable-router fallback steps logged with `policy_kind` field on `RouterStep`; GRPO filter excludes fallback. β†’ Β§2 A3 + Decision 65 added.
843
+
844
+ ### Additional pins resolved during Phase A review pass
845
+
846
+ - **Item A β†’ resolved.** Backward re-entry threshold pinned at `preserved_dissent_count >= 2`. β†’ Β§3 transition rules updated.
847
+ - **Item B β†’ resolved.** Cross-brain Critic USR includes BOTH target's and challenger's perception (~200 extra tokens / challenge). β†’ Decision 27 updated.
848
+ - **Item C β†’ resolved.** Round-2 entry: only via explicit `switch_phase(Divergence)` from router. β†’ Β§3 transition rules + Decision 61 added.
849
+ - **Item D β†’ resolved.** Round-2 `prior_belief` when round 1 failed: empty `BeliefState`, NOT `None`. β†’ Decision 62 added.
850
+ - **Item E β†’ resolved.** No V2-brain stub lens functions; `lens_for(brain, obs)` raises `KeyError` on V2 brain ids. β†’ Decision 9 updated.
851
+ - **Item F β†’ resolved.** Phase-to-protocol mapping pinned (steps 1, 2, 3, 5 β†’ MVP phases; step 4 β†’ V2-deferred). β†’ Β§3 phase-to-protocol mapping subsection added.
852
+
853
+ ### Inconsistency resolved during Phase A review pass
854
+
855
+ - **Decision 38 inconsistency β†’ resolved.** Hardcoded `request_challenge(challenger=logistics, target=epidemiology)` replaced with dynamic pair: `challenger = brain with min(top_confidence)`, `target = brain with max(top_confidence)`, ties broken by Decision 26's deterministic ordering. β†’ Decision 38 updated.
856
 
857
  ---
858
 
 
942
 
943
  ### Word count
944
 
945
+ β‰ˆ 8,275 words after the Phase A review pass β€” about 275 over the
946
+ original 8,000 soft ceiling. (Initial draft: β‰ˆ 6,529 words; review
947
+ pass added β‰ˆ 1,750 words of resolution prose, including per-resolution
948
+ "why rejected" rationale to keep Β§9's decision-format consistent.)
949
+ The overage is accepted as the cost of folding all 13 resolutions
950
+ inline rather than as a separate addendum file β€” single source of
951
+ truth for Sessions 9–13.
952
 
953
  ### Sections completed (10/10)
954
 
955
+ Β§1 Data flow / Β§2 Schemas / Β§3 Phase machine (now includes phase-to-
956
+ protocol mapping) / Β§4 Hard caps + dissent / Β§5 Token budget /
957
+ Β§6 Routing policy / Β§7 Failure modes / Β§8 Test strategy / Β§9 Pre-
958
+ approved decisions (65 entries β€” 60 initial + 5 review-pass additions) /
959
+ Β§10 Sequencing.
960
 
961
  ### Decisions auto-resolved (rationales recorded inline in Β§9)
962
 
963
+ 65 modeling decisions, grouped by layer:
964
  - 8 subagent decisions
965
  - 6 lens decisions
966
  - 7 brain executive decisions
 
970
  - 3 failure / fallback decisions
971
  - 4 testing decisions
972
  - 12 tooling / V2-deferral decisions
973
+ - **5 review-pass additions (61–65)**: round-2 entry mechanism,
974
+ round-2 `prior_belief` encoding, `salient_signals` cap, training-
975
+ rollout temperature deferral, `RouterStep.policy_kind` GRPO filter.
976
+
977
+ ### Phase A review pass β€” resolutions (April 2026)
978
 
979
+ All 4 D-FR items, 3 OQ items, 6 additional pins (Items A–F), and 1
980
+ Decision-38 inconsistency resolved. Each is folded into the relevant
981
+ inline decision; the Β§9 "resolved during Phase A review pass"
982
+ subsection lists the cross-references for traceability.
983
+
984
+ | ID | Resolution (1-line) | Lands in |
985
+ |---|---|---|
986
+ | D-FR-1 | Conservative-only `< 0.4`; aggressive variant rejected. | Decision 28 |
987
+ | D-FR-2 | Vote weight stays `top_confidence Γ— evidence_count`; no extra `(1 - uncertainty)` factor (Decision 16 already bakes it in). | Decision 25 |
988
+ | D-FR-3 | `parse_failure_marker` fires only on full-brain emptiness; single-subagent failures use empty-report fallback. | Decision 6 |
989
+ | D-FR-4 | `urgency` keeps `worst_region_infection Γ— 0.5`; 1.0 weight rejected. | Decision 36 |
990
+ | OQ-1 | Training-rollout temperature deferred to Session 15. | Decision 64 (new) |
991
+ | OQ-2 | `salient_signals` is free-form `List[str]` capped at 5. | Decision 63 (new) |
992
+ | OQ-3 | `policy_kind` field on `RouterStep`; GRPO filter excludes fallback. | Β§2 A3 + Decision 65 (new) |
993
+ | Item A | Backward re-entry pinned at `preserved_dissent_count >= 2`. | Β§3 transition rules |
994
+ | Item B | Cross-brain Critic USR includes target + challenger perception (~200 extra tokens). | Decision 27 |
995
+ | Item C | Round-2 entry: only via explicit `switch_phase(Divergence)`. | Β§3 + Decision 61 (new) |
996
+ | Item D | Round-2 `prior_belief` when round 1 failed: empty `BeliefState`, NOT `None`. | Decision 62 (new) |
997
+ | Item E | No V2-brain stub lens; `lens_for` raises `KeyError` on V2 brain ids. | Decision 9 |
998
+ | Item F | Phase-to-protocol mapping pinned (steps 1, 2, 3, 5 β†’ MVP phases; 4 β†’ V2-deferred). | Β§3 phase-to-protocol mapping subsection |
999
+ | Decision 38 inconsistency | Hardcoded `(challenger=logistics, target=epidemiology)` β†’ dynamic `(min top_confidence, max top_confidence)`, ties via Decision 26. | Decision 38 |
1000
+
1001
+ ### Standing-by status
1002
+
1003
+ **Decisions locked. Session 9 unblocked.** Phase A is complete; no
1004
+ remaining flagged items, no remaining open questions. Sessions 9–13
1005
+ implement against this document. Future revisions to Phase A
1006
+ contracts require explicit βœ… in a new review pass.
1007
 
1008
  ### What is NOT in this document
1009
 
1010
  - No Python code (per the no-code constraint).
 
 
 
1011
  - No Session 14+ details (training reward composition, eval harness,
1012
  HF Spaces deploy). Phase A intentionally bounds at Session 13.
docs/SMOKE_GATE_RUNBOOK.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Smoke Gate Runbook
2
+
3
+ Use this runbook for the Session 7d/lock-and-test smoke gate on Windows.
4
+
5
+ ## Preferred Shells
6
+
7
+ Use Git Bash or WSL for the canonical command style:
8
+
9
+ ```bash
10
+ docker run -d --rm -p 58300:8000 --name cwc-diag crisisworldcortex-env:7d-smoke
11
+ until curl -sf http://localhost:58300/health >/dev/null 2>&1; do sleep 2; done
12
+ ENV_URL=http://localhost:58300 HF_TOKEN="$HF_TOKEN" uv run python inference.py
13
+ docker logs cwc-diag
14
+ docker stop cwc-diag
15
+ ```
16
+
17
+ ## Windows `cmd.exe`
18
+
19
+ Do not write `set ENV_URL=http://localhost:58300 && uv run ...`.
20
+ `cmd.exe` includes the space before `&&` in the variable value, producing
21
+ bad values such as `58300 ` or URLs with a literal trailing space.
22
+
23
+ Use one assignment per line:
24
+
25
+ ```bat
26
+ set ENV_URL=http://localhost:58300
27
+ set HF_TOKEN=<real-token>
28
+ uv run python inference.py
29
+ ```
30
+
31
+ For Hugging Face Spaces, also clear Docker mode first:
32
+
33
+ ```bat
34
+ set LOCAL_IMAGE_NAME=
35
+ set ENV_URL=https://angshuman28-crisisworldcortex.hf.space
36
+ set HF_TOKEN=<real-token>
37
+ uv run python inference.py
38
+ ```