Skip to content

feat(governor): Lane H PR-4 — PressureBroker → governor pure-function bridge#1369

Merged
joelteply merged 1 commit into
canaryfrom
feat/substrate-governor-pr4-pressure-broker-bridge
May 17, 2026
Merged

feat(governor): Lane H PR-4 — PressureBroker → governor pure-function bridge#1369
joelteply merged 1 commit into
canaryfrom
feat/substrate-governor-pr4-pressure-broker-bridge

Conversation

@joelteply
Copy link
Copy Markdown
Contributor

Summary

Pure-function bridge between PressureBroker's PressureAlert surface (disk/memory pool eviction events) and the governor's typed PressureSignal cascade input. Per GENOME-FOUNDRY-SENTINEL.md Part 11 line 1121: "PressureBroker informs the SubstrateGovernor. Pressure signals from the broker drive the governor's adjustment cascade."

Scope

  • alert_to_signal(&PressureAlert) -> Option<PressureSignal> — pure mapping. High/Critical tier → SystemMemHigh{used_pct}; Normal/Warning/unknown → None.
  • governor_alert_sink(Arc<dyn SubstrateGovernor>) -> AlertSink — factory that wraps a governor as an AlertSink the broker can register via PressureBroker::add_alert_sink. Sink derives the signal and forwards via governor.on_pressure_signal when Some; drops when None.

NOT in this PR (deferred)

  • Wiring the sink into PressureBrokerModule's boot path — separate concern. The bridge is the data-side primitive; wiring is PR-5.
  • Pool-name-aware mapping (vram → VRAMHigh, docker → potential DiskHigh variant). Today's broker pools are all memory-adjacent (Docker disk, HF cache, future VRAM via GpuMemoryManager); SystemMemHigh is the conservative single-mapping the cascade reacts to identically. Refinement when pool tier_name conventions stabilize.

Discipline

  • No silent default-on-error. Mapping is total — every alert maps to either Some(signal) or None explicitly.
  • Pressure clamped to [0.0, 1.0] before percent conversion so transient over-budget snapshots map to 100% and negative artifacts map to 0% rather than wrapping via as u8.
  • Sink forwards via Arc<dyn SubstrateGovernor> (object-safe trait) so the bridge does not depend on LocalSubstrateGovernor concretely.

Tests (14, all passing)

  • normal/warning/unknown tiers → None (4 tests)
  • high/critical tiers → SystemMemHigh with rounded used_pct (3 tests)
  • pressure clamping above 1.0 + below 0.0 + rounding (3 tests)
  • sink forwarding high/critical + non-forwarding normal/warning (4 tests)
  • sink survives construction-scope drop + multi-call ordering (2 tests)

Full governor suite: 152 passing (138 prior + 14 new).

Lane H 8-PR stack progress

PR-1 (#1330/1331) → PR-2 (#1345) → PR-3a (#1352) → PR-3b (#1354) → PR-3c1 (#1356) → PR-3c2 (#1360) → PR-3c3 (#1364) → PR-3c4 (#1365) → PR-4 (this PR). PR-3d governor file watcher in flight from codex (#1368, parallel branch, no overlap).

Test plan

  • cargo test --package continuum-core --lib --features metal,accelerate governor::pressure_bridge:: — 14/14 pass
  • cargo test --package continuum-core --lib --features metal,accelerate governor:: — 152/152 pass (no regressions)
  • Pre-push TS clean, ESLint baseline held, Rust compile clean
  • CI green (will re-run once canary TS hotfix from codex lands)

🤖 Generated with Claude Code

@joelteply joelteply force-pushed the feat/substrate-governor-pr4-pressure-broker-bridge branch from f2dec2c to aedc0f8 Compare May 17, 2026 03:12
… bridge

Pure-function bridge between PressureBroker's PressureAlert surface
(disk/memory pool eviction events) and the governor's typed
PressureSignal cascade input. Per GENOME-FOUNDRY-SENTINEL.md Part 11
line 1121: "PressureBroker informs the SubstrateGovernor. Pressure
signals from the broker drive the governor's adjustment cascade."

Scope:
- `alert_to_signal(&PressureAlert) -> Option<PressureSignal>` — pure
  mapping. High/Critical tier → SystemMemHigh{used_pct}; Normal/
  Warning/unknown → None.
- `governor_alert_sink(Arc<dyn SubstrateGovernor>) -> AlertSink` —
  factory that wraps a governor as an AlertSink the broker can register
  via `PressureBroker::add_alert_sink`. Sink derives the signal and
  forwards via `governor.on_pressure_signal` when Some; drops when None.

NOT in this PR (deferred to PR-5):
- Wiring the sink into PressureBrokerModule's boot path. The bridge is
  the data-side primitive; the wiring is a separate concern.
- Pool-name-aware mapping (vram → VRAMHigh, etc.). Today's broker pools
  are all memory-adjacent (Docker disk, HF cache, future VRAM via
  GpuMemoryManager); SystemMemHigh is the conservative single-mapping
  the cascade reacts to identically. Refinement when pool tier_name
  conventions stabilize.

Discipline:
- No silent default-on-error. Mapping is total — every alert maps to
  either Some(signal) or None explicitly.
- Pressure clamped to [0.0, 1.0] before percent conversion so transient
  over-budget snapshots map to 100% and negative artifacts map to 0%
  rather than wrapping via `as u8`.
- Sink forwards via `Arc<dyn SubstrateGovernor>` (object-safe trait) so
  the bridge does not depend on LocalSubstrateGovernor concretely.

Tests (14, all passing):
- normal/warning/unknown tiers -> None (4 tests)
- high/critical tiers -> SystemMemHigh with rounded used_pct (3 tests)
- pressure clamping above 1.0 + below 0.0 + rounding (3 tests)
- sink forwarding high/critical + non-forwarding normal/warning (4 tests)
- sink survives construction-scope drop + multi-call ordering (2 tests)

Lane H 8-PR stack progress: PR-1 (#1330/1331) -> PR-2 (#1345) -> PR-3a
(#1352) -> PR-3b (#1354) -> PR-3c1 (#1356) -> PR-3c2 (#1360) -> PR-3c3
(#1364) -> PR-3c4 (#1365) -> **PR-4 (this PR)**. PR-3d governor file
watcher in flight from codex on parallel branch (no overlap).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@joelteply joelteply force-pushed the feat/substrate-governor-pr4-pressure-broker-bridge branch from aedc0f8 to 2f64811 Compare May 17, 2026 03:28
@joelteply joelteply merged commit 87268aa into canary May 17, 2026
3 checks passed
@joelteply joelteply deleted the feat/substrate-governor-pr4-pressure-broker-bridge branch May 17, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant