Repository navigation
feat(inference): CBAR-PIECE-5 PR-3 — hardware probe populates HardwareProfile - #1335
Merged
Merged
Conversation
This was referenced May 16, 2026
joelteply
pushed a commit
that referenced
this pull request
May 16, 2026
…ning; navigate to MODULE-CATALOG queue Second refresh of ALPHA-GAP Immediate Next Actions to reflect work landed since #1316 merged. Six items closed; navigation into MODULE-CATALOG queue made explicit. Closed: #6 contract widening (#1341), #8 GRID-INFERENCE-ROUTING PR-1 (#1315), CBAR-PIECE-5 end-to-end (#1331/#1333/#1335/#1338), PIECE-8 inference-grpc hardcoded-clamps (#1340), doc family architecture surface (#1324/#1327/#1332/#1336/#1337 open; #1316/#1317/#1320/#1329 merged). Item #9 reorganized to point at MODULE-CATALOG's 'Next Modules To Build' queue (audit-recorder → threat-detector → working-set-manager → demand-aligned-recall → substrate-governor). Adds closeout summary section listing what's done, what's open (5 architecture-doc PRs ready for review + 2 airc PRs), and what's queued (5 modules with dependency state + LoC + acceptance criteria in MODULE-CATALOG). Doc-driven development cycle is working: doc spec → implementing agent picks up → ships PR → next spec referenced.
joelteply
added a commit
that referenced
this pull request
May 16, 2026
…ning; navigate to MODULE-CATALOG queue (#1342) Second refresh of ALPHA-GAP Immediate Next Actions to reflect work landed since #1316 merged. Six items closed; navigation into MODULE-CATALOG queue made explicit. Closed: #6 contract widening (#1341), #8 GRID-INFERENCE-ROUTING PR-1 (#1315), CBAR-PIECE-5 end-to-end (#1331/#1333/#1335/#1338), PIECE-8 inference-grpc hardcoded-clamps (#1340), doc family architecture surface (#1324/#1327/#1332/#1336/#1337 open; #1316/#1317/#1320/#1329 merged). Item #9 reorganized to point at MODULE-CATALOG's 'Next Modules To Build' queue (audit-recorder → threat-detector → working-set-manager → demand-aligned-recall → substrate-governor). Adds closeout summary section listing what's done, what's open (5 architecture-doc PRs ready for review + 2 airc PRs), and what's queued (5 modules with dependency state + LoC + acceptance criteria in MODULE-CATALOG). Doc-driven development cycle is working: doc spec → implementing agent picks up → ships PR → next spec referenced. Co-authored-by: Test <[email protected]>
This was referenced May 16, 2026
joelteply
added a commit
that referenced
this pull request
May 16, 2026
Per GENOME-FOUNDRY-SENTINEL #1327 Part 11 Lane H PR sequence: 1. governor-types: SubstrateGovernor, GovernorPolicy, HardwareClass, hardware detection at boot ← THIS PR 2. tier-stores: five TierStore impls + WorkingSetManager 3. recall-api: DemandAlignedRecall trait + scoring 4. composer-speculator: Composer + Speculator 5. foundry-skeleton: Foundry trait + Qwen absorber 6. sentinel-skeleton: SentinelAI trait + trace consumption 7. sharing-protocol-local-first: SharingProtocol LocalInstance Pure typed surface + bridge from inference_capability::hw_probe (PIECE-5 PR-3 #1335). No impl, no TOML loader, no cascade state machine. PR-3 ships the reference LocalSubstrateGovernor with TOML + cascade. What ships in src/workers/continuum-core/src/governor/: mod.rs: - SubstrateGovernor trait (current_policy + on_hardware_detected + on_pressure_signal + snapshot). PR-3 ships the reference impl. types.rs: - HardwareClass struct + supporting enums (TargetSilicon, PowerSource, ThermalClass, ThermalSeverity) - GovernorPolicy struct + sub-structs (TierSizes, CadenceMultipliers, ConcurrencyCaps, FederationCadence, RecallScoreWeights) + enums (SpeculationLevel, ConsolidationSchedule) - PressureSignal enum (Thermal/BatteryLow/SystemMemHigh/VRAMHigh/ UserActive/InferenceQueueDepth/SpeculationMissRate) - GovernorSnapshot for telemetry - classify_hardware(profile) pure fn — bridges hw_probe's HardwareProfile to HardwareClass Failure-mode discipline (matches no_silent_fallback rule): - classify_silicon ordered: AppleM > NvidiaCuda > IntelVulkan > None. No silent guess; None surfaces 'no GPU' upstream where the inference gate (PIECE-5) refuses turns. - power_source defaults to Plugged when undetermined (matches spec's 'favor performance when we can't tell'). - thermal_class default to Workstation is documented; PR-2 wires proper IORegistry/DMI probe. - battery_pct + thermal_headroom_pct are None in PR-1 (no probe yet); test pins the absence so PR-2 fills. - UMA convention: Apple Silicon reports vram_mb=0 so the policy file computes inference budget as system_ram fraction (matches spec). Tests: 36 passing on cargo test --lib --features metal,accelerate governor:: - classify_silicon (4 paths: AppleM, NvidiaCuda, IntelVulkan, None) - UMA vram=0 convention + discrete vram = actual VRAM - thermal_class derivation (Air→ThinAndLight, M5 Pro→Workstation, iOS→Mobile, server→Server, unknown→Workstation default) - power_source default + battery/thermal-headroom None - TargetSilicon serializes kebab-case - HardwareClass round-trips camelCase - GovernorPolicy round-trips with every field populated - PressureSignal tagged-union round-trips with 'kind' discriminator - ThermalSeverity + SpeculationLevel ordered (Cool<Warm<Hot<Critical; Off<Conservative<Balanced<Aggressive) — cascade thresholds depend - GovernorSnapshot includes full policy - ts-rs export bindings (15 types in shared/generated/governor/) Stack: - #1335 hardware probe (MERGED) — input to classify_hardware - This PR: typed surface + bridge - Future PR-2: tier-stores + WorkingSetManager (codex's claim) - Future PR-3: TOML policy loader + cascade state machine + arc_swap publish (the reference LocalSubstrateGovernor impl) - Future PR-4: PressureBroker → governor wiring (consumes PressureSignal events) VDD evidence N/A — pure types + pure derivation. Evidence with PR-3 when the actual policy reads + writes happen. Co-authored-by: Test <[email protected]>
joelteply
pushed a commit
that referenced
this pull request
May 16, 2026
Per GENOME-FOUNDRY-SENTINEL #1327 Part 11 'Policy File Format'. Stacks on #1345 (PR-1 governor-types). What ships in src/workers/continuum-core/src/governor/policy_file.rs: - PolicyFile + file-format sibling structs (TierSizesFile, CadenceMultipliersFile, ConcurrencyCapsFile, FederationCadenceFile, RecallScoreWeightsFile, SpeculationFileSection, ConsolidationFileSection) — snake_case for TOML idiom, separate from wire-format camelCase types in types.rs - parse_policy_text(text) — pure parser (no I/O), testable with embedded TOML strings - load_policy_file(path) — thin file-opener wrapping parse_policy_text - validate() — enforces semantic invariants: * recall_weights sum to 1.0 within RECALL_WEIGHTS_TOLERANCE (0.01) * tier_sizes all > 0 (zero would disable a tier; not supported) * cadence_multipliers >= 1.0 (< 1.0 would speed up cadence; typo) - into_governor_policy(file, hw_class, ts) — composes file + caller- supplied HardwareClass + timestamp into the published GovernorPolicy - PolicyFileError typed enum with Display + Error + From for io::Error + toml::de::Error Failure-mode discipline: - imbalanced recall_weights returns RecallWeightsImbalanced { sum, tolerance } — not silently rescaled. Operator sees what they typed. - zero tier_size returns InvalidTierSize { field, value } per-field. - cadence_multiplier < 1.0 returns InvalidCadenceMultiplier { field, value }. - TOML syntax errors propagate as PolicyFileError::Toml. - Missing file returns PolicyFileError::Io with the path named. Tests: 17 passing on cargo test --lib --features metal,accelerate governor::policy_file:: - canonical M-Air policy parses + validates (from spec) - canonical Blackwell 5090 policy parses + validates (same schema, larger numbers — pins scaling) - imbalanced recall_weights rejected (with sum named) - exact-1.0 recall_weights accepted (boundary) - zero l1_lora_layers rejected (with field named) - zero any tier_size rejected (loop over all fields) - cadence_multiplier < 1.0 rejected (with field + value) - cadence_multiplier = 1.0 accepted (boundary) - into_governor_policy composes correctly with hw_class - load_policy_file reads valid file (I/O smoke) - load_policy_file nonexistent → Io err - load_policy_file invalid TOML → Toml err - PolicyFileError Display + Error trait - From<io::Error> + From<toml::de::Error> - SpeculationLevel kebab-case strings parse (off/conservative/balanced/aggressive) - ConsolidationSchedule kebab-case strings parse (always/idle/idle-plugged-in/manual) - full pipeline: hw_probe → classify_hardware → parse_policy_text → into_governor_policy Stack: - #1335 hw_probe (MERGED) - #1345 PR-1 governor-types (OPEN) - This PR (PR-2): TOML loader + validator - Future PR-3: file watcher (notify crate) + policy selection by HardwareClass fingerprint + cascade state machine + LocalSubstrateGovernor reference impl + arc_swap publish - Future PR-4: PressureBroker → governor wiring VDD evidence N/A — pure parser + validator. Evidence with PR-3 when governor reads policy in production.
joelteply
pushed a commit
that referenced
this pull request
May 16, 2026
Per GENOME-FOUNDRY-SENTINEL #1327 Part 11 'Policy File Format'. Stacks on #1345 (PR-1 governor-types). What ships in src/workers/continuum-core/src/governor/policy_file.rs: - PolicyFile + file-format sibling structs (TierSizesFile, CadenceMultipliersFile, ConcurrencyCapsFile, FederationCadenceFile, RecallScoreWeightsFile, SpeculationFileSection, ConsolidationFileSection) — snake_case for TOML idiom, separate from wire-format camelCase types in types.rs - parse_policy_text(text) — pure parser (no I/O), testable with embedded TOML strings - load_policy_file(path) — thin file-opener wrapping parse_policy_text - validate() — enforces semantic invariants: * recall_weights sum to 1.0 within RECALL_WEIGHTS_TOLERANCE (0.01) * tier_sizes all > 0 (zero would disable a tier; not supported) * cadence_multipliers >= 1.0 (< 1.0 would speed up cadence; typo) - into_governor_policy(file, hw_class, ts) — composes file + caller- supplied HardwareClass + timestamp into the published GovernorPolicy - PolicyFileError typed enum with Display + Error + From for io::Error + toml::de::Error Failure-mode discipline: - imbalanced recall_weights returns RecallWeightsImbalanced { sum, tolerance } — not silently rescaled. Operator sees what they typed. - zero tier_size returns InvalidTierSize { field, value } per-field. - cadence_multiplier < 1.0 returns InvalidCadenceMultiplier { field, value }. - TOML syntax errors propagate as PolicyFileError::Toml. - Missing file returns PolicyFileError::Io with the path named. Tests: 17 passing on cargo test --lib --features metal,accelerate governor::policy_file:: - canonical M-Air policy parses + validates (from spec) - canonical Blackwell 5090 policy parses + validates (same schema, larger numbers — pins scaling) - imbalanced recall_weights rejected (with sum named) - exact-1.0 recall_weights accepted (boundary) - zero l1_lora_layers rejected (with field named) - zero any tier_size rejected (loop over all fields) - cadence_multiplier < 1.0 rejected (with field + value) - cadence_multiplier = 1.0 accepted (boundary) - into_governor_policy composes correctly with hw_class - load_policy_file reads valid file (I/O smoke) - load_policy_file nonexistent → Io err - load_policy_file invalid TOML → Toml err - PolicyFileError Display + Error trait - From<io::Error> + From<toml::de::Error> - SpeculationLevel kebab-case strings parse (off/conservative/balanced/aggressive) - ConsolidationSchedule kebab-case strings parse (always/idle/idle-plugged-in/manual) - full pipeline: hw_probe → classify_hardware → parse_policy_text → into_governor_policy Stack: - #1335 hw_probe (MERGED) - #1345 PR-1 governor-types (OPEN) - This PR (PR-2): TOML loader + validator - Future PR-3: file watcher (notify crate) + policy selection by HardwareClass fingerprint + cascade state machine + LocalSubstrateGovernor reference impl + arc_swap publish - Future PR-4: PressureBroker → governor wiring VDD evidence N/A — pure parser + validator. Evidence with PR-3 when governor reads policy in production.
joelteply
added a commit
that referenced
this pull request
May 16, 2026
* feat(governor): Lane H PR-2 — TOML policy file loader + validator Per GENOME-FOUNDRY-SENTINEL #1327 Part 11 'Policy File Format'. Stacks on #1345 (PR-1 governor-types). What ships in src/workers/continuum-core/src/governor/policy_file.rs: - PolicyFile + file-format sibling structs (TierSizesFile, CadenceMultipliersFile, ConcurrencyCapsFile, FederationCadenceFile, RecallScoreWeightsFile, SpeculationFileSection, ConsolidationFileSection) — snake_case for TOML idiom, separate from wire-format camelCase types in types.rs - parse_policy_text(text) — pure parser (no I/O), testable with embedded TOML strings - load_policy_file(path) — thin file-opener wrapping parse_policy_text - validate() — enforces semantic invariants: * recall_weights sum to 1.0 within RECALL_WEIGHTS_TOLERANCE (0.01) * tier_sizes all > 0 (zero would disable a tier; not supported) * cadence_multipliers >= 1.0 (< 1.0 would speed up cadence; typo) - into_governor_policy(file, hw_class, ts) — composes file + caller- supplied HardwareClass + timestamp into the published GovernorPolicy - PolicyFileError typed enum with Display + Error + From for io::Error + toml::de::Error Failure-mode discipline: - imbalanced recall_weights returns RecallWeightsImbalanced { sum, tolerance } — not silently rescaled. Operator sees what they typed. - zero tier_size returns InvalidTierSize { field, value } per-field. - cadence_multiplier < 1.0 returns InvalidCadenceMultiplier { field, value }. - TOML syntax errors propagate as PolicyFileError::Toml. - Missing file returns PolicyFileError::Io with the path named. Tests: 17 passing on cargo test --lib --features metal,accelerate governor::policy_file:: - canonical M-Air policy parses + validates (from spec) - canonical Blackwell 5090 policy parses + validates (same schema, larger numbers — pins scaling) - imbalanced recall_weights rejected (with sum named) - exact-1.0 recall_weights accepted (boundary) - zero l1_lora_layers rejected (with field named) - zero any tier_size rejected (loop over all fields) - cadence_multiplier < 1.0 rejected (with field + value) - cadence_multiplier = 1.0 accepted (boundary) - into_governor_policy composes correctly with hw_class - load_policy_file reads valid file (I/O smoke) - load_policy_file nonexistent → Io err - load_policy_file invalid TOML → Toml err - PolicyFileError Display + Error trait - From<io::Error> + From<toml::de::Error> - SpeculationLevel kebab-case strings parse (off/conservative/balanced/aggressive) - ConsolidationSchedule kebab-case strings parse (always/idle/idle-plugged-in/manual) - full pipeline: hw_probe → classify_hardware → parse_policy_text → into_governor_policy Stack: - #1335 hw_probe (MERGED) - #1345 PR-1 governor-types (OPEN) - This PR (PR-2): TOML loader + validator - Future PR-3: file watcher (notify crate) + policy selection by HardwareClass fingerprint + cascade state machine + LocalSubstrateGovernor reference impl + arc_swap publish - Future PR-4: PressureBroker → governor wiring VDD evidence N/A — pure parser + validator. Evidence with PR-3 when governor reads policy in production. * chore(governor): tighten policy loader diagnostics --------- Co-authored-by: Test <[email protected]>
4 of 5 tasks
joelteply
added a commit
that referenced
this pull request
May 16, 2026
…e traits (+sentinel cleanup) (#1353) * feat(genome): working-set-manager PR-2 — WorkingSetManager + TierStore traits PR-2 of working-set-manager (MODULE-CATALOG §VII + GENOME-FOUNDRY- SENTINEL Parts 2/3/4). Trait surface on top of PR-1's typed data layer (#1346). No implementations — those are PR-3 + the per-role TierStore PRs. Mirrors the slice shape: PR-1 = data, PR-2 = traits, PR-3 = impl + wiring. Same pattern as CBAR-PIECE-2 (data #1321 → traits #1323 → dispatch #1339+#1343) and PIECE-5 (data #1331 → loader #1333 → probe #1335 → enforcement #1338). What lands - `genome::store::TierStore` — the trait every per-role tier implementation satisfies. Five methods: role / read / write / evict / capacity / observe_access. `Send + Sync + async_trait` for tokio concurrency. Used by working-set-manager (PR-3) as `Box<dyn TierStore>` per configured role. - `genome::manager::WorkingSetManager` — the top-level paging interface. Four methods this PR: page_in / page_out / working_set / audit_access. The fifth method `check_permission(actor, region, op)` from GENOME-FOUNDRY-SENTINEL Part 4 lands in PR-3 alongside the GenomeRegion + Op type definitions. - `genome::blob::ArtifactBlob` — bytes-side type for `TierStore::write`. Content-addressed via ArtifactId. NOT ts-rs-exported — large blobs don't belong on the TS wire. - `genome::blob::Provenance` — PR-2 minimal stub (artifact_id + created_at_ms). Full GENOME-FOUNDRY-SENTINEL Part 1 shape grows this type later without breaking the trait surface. Design refinements vs the raw spec - `working_set` returns `Option<&WorkingSet>` instead of `&WorkingSet`. Unregistered persona → `None` instead of fabricating an empty struct that masks wrong-persona-id bugs. - `page_in` returns `Result<PageHandle, PageFault>` per spec. Documented that PageFault is a typed observability signal, not a failure error — caller treats it as success-with-trace-event. Tests 13 new tests on genome::manager + genome::store + genome::blob: trait object-safety, dispatch through Arc/Box, audit_access denial shape, ArtifactBlob size invariant, Provenance wire shape. 48 genome:: tests total (PR-1's 35 + PR-2's 13). No regressions across the other 2487 lib tests. Stack #1339 / #1343 — CBAR-PIECE-2 PR-3 artifact dispatch (mine) #1344 — audit-recorder (codex's, subscribes to AccessDenied) #1346 — working-set-manager PR-1: data types (mine) THIS PR — working-set-manager PR-2: traits (mine) NEXT — working-set-manager PR-3: per-persona impl + PageFault / EvictionRecord publishing via artifact dispatch path Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(sentinel): remove dead self_clone — was masking under -D warnings test build Drift from canary HEAD: src/workers/continuum-core/src/modules/sentinel/mod.rs:1039 defined `let self_clone = Arc::new(self.sentinels.clone());` and never referenced it. The actual clone used downstream is `let sentinels = Arc::clone(&self.sentinels);` at line 1066 (now 1065 after this fix). Why it bit me: the test build for genome PR-2 (#1346 stack) `cargo test --lib --features metal,accelerate` is the gate the prepush hook runs, and that build has -D warnings effectively-on for unused_variables — so the warning became "error: could not compile." This blocks every Rust-touching push until fixed. Per Joel's boy-scout-rule + "Bugs from new users / new machines / new OS are GIFTS — fix the source, never hack": dead-code fix in place, sweeping as I go. This is NOT genome-PR-2 scope but is REQUIRED for the precommit gate to let genome-PR-2 through. Bundling here keeps the gate working; splitting it into a separate PR would block PR-2's push behind a fix that has nothing to do with PR-2's logic. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(genome): scope uuid::Uuid import to test module in blob.rs Earlier fix in this branch removed `use uuid::Uuid;` from file scope because clippy on `cargo check --lib` flagged it unused. But the TEST module uses `Uuid::nil()` — `cargo test --lib` failed with E0433 "use of undeclared type Uuid" once the test build saw the references. Fix: move the import inside `#[cfg(test)] mod tests` so it lives where it's used. Clippy on the non-test build sees no Uuid usage in production code (correct — Provenance::minimal doesn't need it), and the test build sees the import where the test fixtures need it. 48/48 genome:: tests pass after the fix. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Test <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
May 16, 2026
Stacks on #1352 (codex's PR-3a policy_selector, MERGED). Per GENOME-FOUNDRY-SENTINEL #1327 Part 11. LocalSubstrateGovernor is the reference impl of the SubstrateGovernor trait (from #1345 PR-1). Holds the live policy behind arc_swap for wait-free reads; mutex-protected snapshot history for telemetry. What ships in src/workers/continuum-core/src/governor/local.rs: - LocalSubstrateGovernor struct: Arc<ArcSwap<GovernorPolicy>> for policy + Mutex<SnapshotState> for cascade-transition-count + recent-signals ring - new(initial_policy) constructor — ready to serve current_policy() immediately - set_candidates(Vec<PolicyFile>) — file watcher (PR-3d) will call this on fs change events; for PR-3b, set manually - try_hardware_detected(hw) → Result<(), PolicySelectionError> — fallible variant for callers that want the typed error - on_hardware_detected(hw) — trait method, swallows errors per spec (logs/telemetry surface them separately) - on_pressure_signal(signal) — records into ring (PR-3c adds threshold + cascade logic; PR-3b only records) - snapshot() → GovernorSnapshot — telemetry consumer reads this - candidate_count() — diagnostic for 'did the file watcher load anything?' Concurrency model (matches spec's 'never blocks reads'): - Reads: arc_swap.load_full() → Arc<GovernorPolicy> clone (wait-free) - Writes: arc_swap.store(Arc::new(new_policy)) + mutex on snapshot state for transition-count bump (~µs hold) - Tests prove the wait-free guarantee: many_concurrent_reads_dont_block + concurrent_read_during_write_sees_consistent_snapshot What this PR DOES NOT do: - Cascade state machine + threshold/hysteresis (PR-3c) - File watcher / hot reload (PR-3d) - PressureBroker subscription wiring (PR-4) - Built-in default policy fallback (caller handles NoMatchingPolicy) Failure-mode discipline: - on_hardware_detected with no matching candidate KEEPS previous policy (trait swallows error per spec — operator monitors via snapshot.cascade_transition_count which stays unchanged on Err) - on_hardware_detected with empty candidates is a no-op (first-boot before file watcher loads anything — governor still serves initial_policy) - cascade_transition_count increments per PUBLISH, not per call — failed selections don't count - on_pressure_signal does NOT bump cascade_transition_count in PR-3b (test pins this so PR-3c lands the threshold logic together) Tests: 16 passing on cargo test --lib --features metal,accelerate governor::local:: (79 total governor:: across PR-1/PR-2/PR-3a/PR-3b) - new() serves initial policy immediately - candidate_count reflects set_candidates - on_hardware_detected publishes matching policy - try_hardware_detected returns NoMatchingPolicy err - on_hardware_detected no-match KEEPS previous policy - on_hardware_detected empty candidates no-op - Successive hardware_detected publishes multiple times - on_pressure_signal records signal - recent_signals ring capped at RECENT_SIGNALS_CAPACITY=32 (FIFO eviction) - snapshot includes policy + signals - cascade_transition_count increments per publish - cascade_transition_count UNCHANGED on no-match - on_pressure_signal does NOT transition in PR-3b (PR-3c adds it) - many_concurrent_reads_dont_block (Arc<Self> + 16 threads × 1000 reads each) - concurrent_read_during_write_sees_consistent_snapshot (writer mutates + reader observes Arc snapshots that are always one of {1, 2, 8} — no torn read) - current_policy returns same Arc when no writes (Arc::ptr_eq) Added deps: arc-swap = '1.7' (tiny crate, no transitive deps). Coordination: ceded my own PR-3a (#1351 closed) in favor of codex's #1352 which has stricter AmbiguousPolicy refusal + hardware_fingerprint diagnostic surface. This PR-3b rebased onto codex's policy_selector API (arg order: select_policy(policies, hw), not (hw, policies)) + imports updated. Stack: - #1335 hw_probe (MERGED) - #1345 PR-1 governor-types (MERGED) - #1350 PR-2 TOML loader (MERGED) - #1352 PR-3a policy_selector (codex's, MERGED) - This PR (PR-3b): LocalSubstrateGovernor + arc_swap publish - Future PR-3c: cascade state machine + hysteresis (5 steps; restore- speculation-one-step-later anti-oscillation rule per spec) - Future PR-3d: file watcher (notify crate) - Future PR-4: PressureBroker → governor wiring VDD evidence N/A — pure-state impl. Evidence with PR-3c when the cascade is wired + with PR-4 when actual pressure signals flow. Co-authored-by: Test <[email protected]>
4 of 5 tasks
joelteply
added a commit
that referenced
this pull request
May 16, 2026
…rocess impl (#1355) PR-3 of working-set-manager. Hangs the per-persona behaviors on the PR-1 data layer (#1346) + PR-2 trait surface (#1353). Pure local implementation — no MessageBus integration baked in (the trait's `page_in` Result already carries `PageFault` as the typed observability signal; callers wire to the artifact dispatch path #1339+#1343 themselves). Mirrors the slice shape: PR-1 = data, PR-2 = traits, PR-3 = impl. Same pattern as CBAR-PIECE-2 (data #1321 → traits #1323 → dispatch #1339+#1343) and PIECE-5 (data #1331 → loader #1333 → probe #1335 → enforcement #1338). What lands - `LocalWorkingSetManager` struct holding: - `Vec<Arc<dyn TierStore>>` — tier chain, ordered Fast → Frozen - `RwLock<HashMap<PersonaId, WorkingSet>>` — per-persona state - `RwLock<HashMap<PageRef, PersonaId>>` — page-ownership map for the MMU-style `audit_access` enforcement - Four trait method impls: - `page_in` — fast-path resident hit, otherwise walks tier chain top-down, returns PageFault with typed from_role/to_role (None from_role = true cold miss; Some = tier promotion) - `page_out` — removes from working set, observes target tier, skips pinned pages silently, returns `TierError::RoleNotConfigured` if the target tier isn't in the configured Vec - `working_set` — returns None per refined contract (lock-guard escape impossible through the trait signature; tests use the `working_set_snapshot` helper instead) - `audit_access` — checks page_owners map; returns typed `AccessDenied` with full context (actor + owner + reason) on cross-persona read - Two convenience methods: - `register_persona(persona, capacity)` — must be called before any page_in for the persona - `register_page_owner(page, owner)` — populates the MMU table - Diagnostic helper: - `working_set_snapshot(persona)` — clones for telemetry + tests Deliberately deferred (PR-4 or later) - MessageBus integration for PageFault/EvictionRecord publishing. The trait's Result<PageHandle, PageFault> contract gives caller- side observability today; bus publishing can stay caller-side too (and the artifact dispatch I shipped in #1339+#1343 is the publishing path when callers wire it). - Eviction policy invocation when target tier is at limit. PR-3 returns NoEvictionCandidate; PR-4 wires the callback so the manager observes + re-publishes the EvictionRecord. - `check_permission(actor, region, op)` — needs GenomeRegion + Op type definitions; lands with PR-4. Refinements to the PR-2 trait contract - `working_set` returns `None` because borrowing through the RwLock would expose the lock guard type and break the trait signature. Documented in the impl + the trait docstring. Tests + telemetry use `working_set_snapshot` (clone, not on hot path). Tests 8 new tests on genome::local_manager: - page_in_resident_returns_cached_without_tier_walk — hot-path correctness (whole point of a working set) - page_in_walks_tier_chain_and_records_promotion — Fast → Bench → Cold walk order, PageFault.from_role + to_role correctness - page_in_true_cold_miss_has_none_from_role — typed signal sentinel uses to distinguish "page never existed" - audit_access_denies_cross_persona_read — typed AccessDenied with full context, same contract PR-2's trait test pins - page_out_observes_target_tier_and_handles_unconfigured — typed RoleNotConfigured for "this hardware doesn't have that role" - page_out_skips_pinned_pages_silently — composition pin contract - working_set_snapshot_reflects_page_in_state — diagnostic helper - tier_count_reflects_configured_tiers — O(1) governor diagnostic 56 genome:: tests total (PR-1's 35 + PR-2's 13 + PR-3's 8). No regressions across other 2566 lib tests. Stack #1339 / #1343 — CBAR-PIECE-2 PR-3 artifact dispatch (mine) #1344 — audit-recorder (codex's, subscribes to AccessDenied) #1346 — working-set-manager PR-1: data types (mine) #1353 — working-set-manager PR-2: traits (mine) THIS PR — working-set-manager PR-3: per-process impl (mine) NEXT — PR-4: bus integration + eviction-callback wiring + check_permission + GenomeRegion/Op types Co-authored-by: Test <[email protected]> Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
joelteply
added a commit
that referenced
this pull request
Jun 15, 2026
…ifiedMemory CPU-floor default (#1628) * feat(inference): coordinator detects hardware silicon — retire the UnifiedMemory CPU-floor default Joel flagged the InferenceCoordinatorModule (#1619) shipping `TargetSilicon::UnifiedMemory` as the production default — the CPU/Mac-floor anchoring "GPU or bust" forbids. This wires the coordinator to the governor's existing hardware detection (Mac's #1335 hw_probe + classify_hardware, already on canary) so the prod default FOLLOWS the hardware instead of a hardcoded floor. - `coordinator_silicon_for(GovernorSilicon) -> TargetSilicon` — the seam between governor classification and the lane scheduler: AppleM → UnifiedMemory; NvidiaCuda/AmdRocm/IntelVulkan → Gpu; None → Cpu (honest, not a silent GPU pretense). (Per Mac's #1618 review: this bridge is the net-new code I own at the seam, since the two TargetSilicon enums don't share variants.) - `CoordinatorConfig::for_silicon(silicon)` — canonical floor-shape builder retargeted to a silicon class; `realistic_floor_default()` now delegates to `for_silicon(UnifiedMemory)` (de-dup); `detected()` = probe_hardware_profile → classify_hardware → translate → for_silicon. - `InferenceCoordinatorModule::with_detected_hardware()` (new production constructor) + ipc/mod.rs boot uses it. On the RTX 5090 the coordinator now targets `Gpu`; on Apple Silicon, `UnifiedMemory`; GPU-less, `Cpu`. One-shot startup probe (a few file reads + per-backend FFI) — acceptable per CONCURRENCY-STYLE-GUIDE. Per-tier budgets stay the realistic-floor numbers until the governor's policy-file slice refines them; this fixes the SILICON label, which is what Joel called out. Validated rust:1.95 (continuum-core --lib): 6 tests pass (translation maps discrete GPU→Gpu not floor / AppleM→UnifiedMemory / None→Cpu; for_silicon targets one silicon end-to-end; detected() self-consistent), whole lib compiles (no inference→governor cycle), CARGO_EXIT=0. Co-Authored-By: Claude Opus 4.8 <[email protected]> * chore(inference): drop dead with_realistic_floor, fix stale doc + test comment (reviewer nits, #1628) Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
CBAR-PIECE-5 PR-3. PR-1 (#1331) defined the gate types. PR-2 (#1333) reads model metadata from disk. This PR-3 populates the OTHER input to the gate — the live hardware profile — by probing Metal / CUDA / Vulkan independently and combining the result with CPU + RAM from sysinfo.
After this PR lands, the gate is end-to-end callable in production code:
probe_hardware_profile() + read_qwen_model_metadata(path) → check_residency_gate(). PR-4 wires the gate into the actual turn dispatcher with enforcement.Why probe each backend independently
gpu::memory_manager::detect_gpu()returns the FIRST backend that succeeds (Metal → CUDA → Vulkan → panic). That's correct for the productionGpuMemoryManager— only one budget per node — but wrong forHardwareProfile, which has separatehas_metal/has_cuda/has_vulkanflags. An NVIDIA-on-Linux host can have BOTH CUDA and Vulkan; the gate'sselect_backenduses the flags to pick CUDA over Vulkan (CUDA's llama.cpp kernels are more complete). If we only set whichever-detected-first, the flags lie.What ships
pub fn probe_hardware_profile() -> HardwareProfile— top-level probe; never panics.pub fn build_hardware_profile(metal, cuda, vulkan, cpu_cores, system_ram_bytes, platform) -> HardwareProfile— pure derivation, 100% deterministic given inputs (the testable layer).try_detect_metal—#[cfg(target_os = "macos")], usesmetal::Device::system_default(). Mirrorsgpu::memory_manager::detect_metalbut returnsNoneinstead of falling through.try_detect_cuda—#[cfg(feature = "cuda")], nvidia-smi subprocess (same pattern asdetect_cuda).try_detect_vulkan—#[cfg(feature = "vulkan")], vulkaninfo subprocess.probe_cpu_and_ram—num_cpus::get()+sysinfo::System.total_memory(), clamped to >=1 cpu.Failure-mode discipline (never panic, never silent)
has_metal=false, has_cuda=false, has_vulkan=false, free_vram=0. Gate then surfacesNoGpuBackendOnNode.num_cpus::get()returns 0sysinfototal_memory failsOption::None— flag stays false, other backends still tried.VRAM aggregation rule
When multiple backends report VRAM (NVIDIA with both CUDA + Vulkan), use the MAX as the shared
total_vram_bytes(same physical card; don't double-count, don't under-count).free_vram_bytes= 95% of total (conservative 5% reserve placeholder). PR-4 wiresGpuMemoryManager::stats().total_used_mbfor the real live free number; PR-3 deliberately doesn't depend on the GpuMemoryManager (heavyweight + panics on no-GPU).Test plan
14 passing on
cargo test --lib --features metal,accelerate inference_capability::hw_probe::build_hardware_profilepure derivation (8):check_residency_gatecleanly (M5 Pro + Qwen2.5-7B passes)NoGpuBackendOnNodeprobe_hardware_profile()doesn't panic on the test runnerbuild_hardware_profiledoesn't silently fix bad inputs (clamping is upstream's job)VDD evidence
N/A — probe is data acquisition, no inference dispatch. Evidence lands with PR-4 (enforcement integration).
What this enables: the gate becomes end-to-end callable in production. Before PR-3,
check_residency_gate(model, hw)required someone to constructhwby hand. Now:check_residency_gate(read_qwen_model_metadata(path)?, &probe_hardware_profile()).Stack