feat patch companion/phase1 feat/companion-app #12 / 15
aaronrene · 4 days ago · Jun 5, 2026 · Diff

feat(companion/phase1): ModelRuntimeAdapter lane selector + consent gate + 7-tier tests

Phase 1 of the Companion App build plan (gate §12, 🔀 Hybrid). Adds the Knowtation-side pure-function seam that Hub/Scooling consume:

lib/model-runtime-lane.mjs: - selectLane(capabilities, preferences) — D2.2 default-lane selection logic; individual: local > self_hosted > enterprise > openrouter > direct_provider > disabled; orgPrivacyMode: never direct_provider; keepOnDevice: biases to local with managed fallback. - isManagedLane(lane) — D1.2 metering boundary; only 'direct_provider' is metered. - enforceConsentPolicy({lane, containsPrivateData, consentId, isDelegate, delegatedManagedAllowed}) — D1.4 consent/policy gate; policy denial beats consent. Returns 'allow' | 'cloud_consent_required' | 'lane_policy_denied'. Pure functions only — no I/O, no env reads, no network; composable at any layer.

docs/COMPANION-APP-PHASE-1-ADAPTER-SEAM.md: Full seam contract spec: types, algorithms, metering×lane matrix, threat model table, Scooling interface additions, and what Phase 2+ builds on this.

test/model-runtime-lane-*.test.mjs (7 tiers, 107 cases, all green): unit, integration, e2e, stress, data-integrity, performance, security. Key security cases: orgPrivacyMode bypass, policy-before-consent evaluation order, private-data-without-consent, fail-closed on empty caps, no secret in return values.

Cross-repo (Scooling): ModelResponse.reason gains 'lane_policy_denied'; createMockModelRuntimeAdapter() updated to return it for delegate actors on managed lane. TypeScript compiles clean (tsc --noEmit: 0 errors).

sha256:06bcc4854a5644481fef328207c64092d93bb8da3e8f6d25949496fa9cb2965d sha
+27 symbols
sha256:111f7098b7d2c0eddae643be2ee0887fd25a53a66d480383a7f389bfbe8fb643 snapshot
+27
symbols added
0
dead code introduced
Semantic Changes 27 symbols
+ Companion App — Phase 1 Adapter Seam Contract section Companion App — Phase 1 Adapter Seam Contract L1–172
+ mjs section 1. Module contract — lib/model-runtime-lane.mjs L25–110
+ 1 LaneCapabilities type section 1.1 LaneCapabilities type L27–40
+ table section table L31–39
+ 2 LanePreferences type section 1.2 LanePreferences type L40–51
+ table section table L44–50
+ 2 default-lane logic section 1.3 selectLane(capabilities, preferences) — D2.2 default-lane logic L51–77
+ code variable variable code L57–69
+ 2 metering boundary section 1.4 isManagedLane(lane) — D1.2 metering boundary L77–88
+ 4 consent/policy gate section 1.5 enforceConsentPolicy(params) — D1.4 consent/policy gate L88–110
+ Scooling interface additions (cross-repo) section 2. Scooling interface additions (cross-repo) L110–132
+ ts) section 2.1 ModelResponse (Scooling src/adapters/types.ts) L112–126
+ code[ts] variable variable code[ts] L116–123
+ 2 createMockModelRuntimeAdapter() update section 2.2 createMockModelRuntimeAdapter() update L126–132
+ 4) section 3. Metering-boundary and lane-mapping summary (D1.2 × D2.4) L132–145
+ table section table L134–142
+ What Phase 2+ builds on this section 4. What Phase 2+ builds on this L145–153
+ Threat model and security properties (invariants under test) section 5. Threat model and security properties (invariants under test) L153–167
+ table section table L155–164
+ Deferred section 6. Deferred L167–172
+ What Phase 1 does NOT produce section What Phase 1 does NOT produce L17–25
+ What Phase 1 produces section What Phase 1 produces L11–17
~ lib/model-runtime-lane.mjs .mjs 3 symbols added
+ enforceConsentPolicy function function enforceConsentPolicy L197–211
+ isManagedLane function function isManagedLane L161–163
+ selectLane function function selectLane L126–146
~ test/model-runtime-lane-e2e.test.mjs .mjs 1 symbol added
+ route function function route L26–39
+ runPipeline function function runPipeline L28–39

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:06bcc4854a5644481fef328207c64092d93bb8da3e8f6d25949496fa9cb2965d --body "your comment"