Skip to content

feat(provider): darkbloom beta command to enable opt-in beta features - #423

Merged
Gajesh2007 merged 2 commits into
masterfrom
feat/provider-beta-features
Jun 20, 2026
Merged

Gajesh2007 merged 2 commits into
masterfrom
feat/provider-beta-features

Conversation

@Gajesh2007

@Gajesh2007 Gajesh2007 commented Jun 20, 2026 •

Copy link
Copy Markdown
Member

What

For the beta tag: a clean, discoverable way for providers to opt into experimental features. Starts with KV-cache quantization (kv-quant), but is a general framework.

darkbloom beta list                 # all features + on/off (default subcommand)
darkbloom beta status [feature]     # details for all, or one
darkbloom beta enable kv-quant      # writes [backend] kv_quant=true
darkbloom restart                   # apply
darkbloom beta disable kv-quant

darkbloom status now also shows a Beta features: line.

Before / after

How a provider enables a beta feature (kv-quant):

Before — only an undocumented TOML field; hand-edit, no discoverability/validation/verification:

flowchart TD
    U([Operator wants ~2x KV capacity]) --> Q{How do I<br/>enable kv-quant?}
    Q -->|no command| NC[no beta command<br/>not shown in status]
    Q -->|not in docs| ND[kv_quant undocumented<br/>absent from quickstart + cli-reference]
    Q -->|env var?| NE[no kv_quant env var exists<br/>and launchd daemon ignores<br/>non-allowlisted DARKBLOOM_*]
    NC --> M[Only path: hand-edit<br/>~/.config/darkbloom/provider.toml]
    ND --> M
    NE --> M
    M --> TY["manually add: [backend] kv_quant = true<br/>typo-prone, no validation, no caveats"]
    TY --> R[darkbloom restart]
    R --> S[serve reads config.backend.kvQuant]
    S --> OK[engaged... but no built-in<br/>way to confirm or see state]

    style ND fill:#ffe9cc,stroke:#cc8400
    style NE fill:#ffe9cc,stroke:#cc8400
    style TY fill:#ffd6d6,stroke:#cc0000
    style OK fill:#ffe9cc,stroke:#cc8400
Loading

After — discoverable, validated, config-backed (reaches the daemon), with a verification path:

flowchart TD
    U([Operator wants ~2x KV capacity]) --> L[darkbloom beta list<br/>discovers kv-quant + on/off state]
    L --> EN[darkbloom beta enable kv-quant]
    EN --> REG[[BetaFeatures registry<br/>kv-quant → backend.kvQuant]]
    REG --> RMW[ConfigManager: load → set → save<br/>writes kv_quant = true to TOML]
    RMW --> HINT[prints model-family caveat<br/>+ 'restart to apply']
    HINT --> R[darkbloom restart]
    R --> D[launchd daemon reads provider.toml<br/>config-backed → always reaches daemon]
    D --> S["serve: kvQuantEnabled = config.backend.kvQuant<br/>(ProviderLoop / StandaloneServer)"]
    S --> RES{BatchScheduler<br/>resolveKVQuantScheme}
    RES -->|Gemma-4 / GPT-OSS| OK([KV-quant engaged ~1.9x capacity])
    RES -->|other family| FP[fp16 fallback - safe]
    OK --> V[Verify: darkbloom status 'Beta features' line<br/>+ darkbloom logs 'kv-quant' logger]

    style OK fill:#d6f5d6,stroke:#1a8a1a
    style V fill:#d6f5d6,stroke:#1a8a1a
    style REG fill:#dbe9ff,stroke:#2b6cb0
    style FP fill:#eeeeee,stroke:#888
Loading

Why a command + config (not docs-only, not env vars)

  • Config-backed, not env-var: the launchd daemon from darkbloom start only inherits an allowlist of two DARKBLOOM_* vars (LaunchAgent.passthroughEnvKeys), so an env-var toggle would silently no-op for the normal daemon. A TOML field is read by every serve path (daemon / --foreground / --local).
  • Command over docs-only: discoverable, validated, prints the model-family caveat + restart hint, and writes the TOML correctly. Hand-editing TOML is error-prone, and kv_quant was previously 100% undocumented.
  • General beta namespace so future beta flags don't clutter the top-level command list.

Design

  • ProviderCore/Config/BetaFeatures.swift — a small registry. Each BetaFeature maps to one ProviderConfig Bool field via @Sendable getter/setter closures (Swift 6 strict-concurrency safe). kv-quant → backend.kvQuant. The command + status are driven entirely off BetaFeatures.all, so adding a beta flag is one entry + a config field.
  • darkbloom/BetaCommand.swift — list / status / enable / disable, modeled on the existing autoupdate read-modify-write precedent (ConfigManager.save). Idempotent no-op when already in the desired state; helpful error (exit 64) on unknown feature; list --json.
  • Default stays off (fp16). No change to gating/runtime — kv-quant just toggles the existing backend.kv_quant field consumed by resolveKVQuantScheme(...).

Docs

  • New docs/provider/beta-features.md (guide + caveats + how to verify via darkbloom logs).
  • kv_quant added to the [backend] reference in quickstart.md.
  • darkbloom beta section in cli-reference.md.

Testing

  • BetaFeaturesTests (7) green: registry lookup (case-insensitive), default-off, apply toggles + is scoped to its field, enabledIDs, TOML round-trip. ConfigTests (16) green.
  • darkbloom CLI builds (Swift 6.1).
  • Manual smoke (temp config): list/enable/persist/json/idempotent/unknown-feature/status/disable all verified.

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

@vercel

vercel Bot commented Jun 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
d-inference Ready Ready Preview Jun 20, 2026 6:42am
d-inference-console-ui-dev Ready Ready Preview Jun 20, 2026 6:42am
d-inference-landing Ready Ready Preview Jun 20, 2026 6:42am

Request Review

@github-actions

github-actions Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

No files in this PR match any affected_files pattern in the threat model; the changes are documentation and CLI UX additions with no direct security-critical code paths touched.


Trust boundaries touched

None of the existing TB-001 through TB-009 boundaries are directly modified. However, the new surface described below warrants a threat model update.


Threat coverage

ℹ️ No existing T-xxx threats are strengthened, weakened, or neutralised by this diff.


New attack surface not covered by an existing threat

BetaFeatures.swift / BetaCommand.swift — feature-flag surface (TB-003 adjacent)

BetaFeatures.swift introduces a persistent feature-flag store (likely on-disk or in UserDefaults/TOML). Two questions that need answers before this can be considered threat-model-neutral:

  1. Where are flags persisted? If flags are stored in a file the operator can edit (e.g. ~/.config/darkbloom/), a malicious operator (ADV-001) could toggle a beta feature that relaxes a security control — for example, disabling encryption, changing the inference backend, or enabling a debug mode — without the coordinator being aware. This is a new instance of the TB-003 "operator vs process" boundary that is not currently modelled.

  2. Are any beta flags gated by attestation? If a flag can enable a code path that changes the provider's security posture (e.g. a different backend type, relaxed SIP checks, or KV-cache behaviour), the coordinator's attestation blob and challenge-response must reflect the active flag state, or the trust level could be based on stale security posture data. Check whether BetaFeatures values are included in the SE-signed attestation blob (AttestationBuilder.swift) or reported in challenge responses.

StatusCommand.swift — information disclosure (TB-003 adjacent)

StatusCommand.swift likely prints local security state (SIP, SE key status, binary hash, etc.) to stdout. Verify that:

  • No private key material, raw SE public key bytes, or unredacted attestation blobs are printed.
  • The command is not callable by other processes without the user's active shell (i.e. it is a CLI subcommand, not an IPC endpoint).

If darkbloom status emits the SE public key or the full attestation blob, that output could be used to pre-compute the MDA freshness code (sha256(SE_public_key_bytes)) as noted under T-033 / TB-009 current limitations.


Recommended threat model additions

New entry Boundary Stride Summary
T-043 (proposed) TB-003 Tampering Operator edits beta feature flags on disk to alter provider security posture without coordinator awareness

The affected_files list for T-013 and T-015 should also be extended to include BetaFeatures.swift and BetaCommand.swift once the flag-persistence mechanism is confirmed.


SEC-* findings resolved

None.


🔐 Threat model: docs/threat-model.yaml · Updates on each push to this PR

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0d97c3be0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}

feature.apply(enabled, to: &config)
try ConfigManager.save(config, to: snapshot.configPath)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Write migrated beta toggles to canonical config

On providers that still have only a legacy config path, loadRuntimeSnapshot copies that file to the canonical ~/.config/darkbloom/provider.toml before returning, but snapshot.configPath remains the legacy path. Saving the toggle back there means the newly created canonical file, which ConfigManager.defaultConfigPath() and the launchd start --foreground daemon resolve first after darkbloom restart, keeps the old kv_quant value, so darkbloom beta enable/disable ... reports success but the restarted daemon ignores it. Save to the post-migration default/canonical path in this case, or ensure the daemon is launched with the same config path.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in a83c5da. When no explicit --config is passed, the toggle now persists to ConfigManager.defaultConfigPath(), which after loadRuntimeSnapshot's legacy→canonical migration resolves to ~/.config/darkbloom/provider.toml (the same path darkbloom restart/the launchd daemon reads first). An explicit --config path is still honored as-is, and the no-op check now tests the actual save target.

Adds a config-backed beta-feature toggle so providers can opt into experimental
capabilities — starting with KV-cache quantization (kv-quant).

- BetaFeature registry (ProviderCore/Config/BetaFeatures.swift): maps each
  feature to a ProviderConfig field (kv-quant -> backend.kvQuant). The command
  and status are driven entirely off this list, so new beta flags need no
  per-feature code.
- `darkbloom beta list|status|enable|disable` modeled on the autoupdate
  read-modify-write precedent; `list` supports --json.
- `darkbloom status` now shows active beta features.
- Docs: docs/provider/beta-features.md, kv_quant added to the [backend]
  reference (quickstart), and a beta section in the CLI reference.

Config-backed (not env-var) on purpose: the launchd daemon only inherits an
allowlist of DARKBLOOM_* vars (LaunchAgent.passthroughEnvKeys), so a TOML field
is the only toggle that reliably reaches the daemon. Default stays off (fp16).

Tests: BetaFeaturesTests (7) + ConfigTests green; darkbloom CLI builds; manual
smoke of enable/disable/list/status/json/unknown-feature paths.
… (Codex P2)

loadRuntimeSnapshot may migrate a legacy config to the canonical
~/.config/darkbloom/provider.toml, but snapshot.configPath stays the legacy
path. Saving the beta toggle there left the canonical file — which the
restarted daemon resolves first — on the stale value, so enable/disable
reported success but the daemon ignored it.

When no explicit --config is given, persist to ConfigManager.defaultConfigPath()
(the post-migration canonical path the daemon reads); honor an explicit
--config path as-is. No-op check now tests the actual save target.
@Gajesh2007

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: a83c5dac96

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Gajesh2007
Gajesh2007 merged commit 89c51f1 into master Jun 20, 2026
15 of 17 checks passed
@Gajesh2007
Gajesh2007 deleted the feat/provider-beta-features branch June 20, 2026 07:02
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…hed SDK base

dev moved its mlx-swift-lm pin to #434 (c85e84cf) and changed tool-call
parsing for GLM, Gemma and MiMo. Conflicts, both kept:
- MultiModelBatchSchedulerEngine.swift, the DEBUG _testMakeEventStream
  parameter list: this branch's withholdReasoning and nativeGlimmerChannels,
  then dev's nativeMiMoChannels (the forwarding call had merged cleanly and
  already passes all three, in makeEventStream's declared order).
- libs/mlx-swift-lm: 39e5dc5e, feat/muse-glimmer-native (#423) with #434
  merged in, so the pin carries both dev's parsers and Muse Glimmer.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…hed SDK base

dev pinned mlx-swift-lm at main fe9b5282 (#434's merge, the same tree as c85e84cf) and says so in
docs/architecture/inference.md, which merged cleanly. Only the libs/mlx-swift-lm gitlink conflicted:
it now pins c1103b8c, feat/muse-glimmer-native (#423) with main fe9b5282 merged in (no file change),
so the pin contains dev's. libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…SDK base

Only the libs/mlx-swift-lm gitlink conflicted. It now pins a071845f, mlx-swift-lm
#428 (speed) with the refreshed feat/muse-glimmer-native (#423 + #434) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…SDK base

Only the libs/mlx-swift-lm gitlink conflicted. It now pins 05330a42, mlx-swift-lm
#428 (speed) with the refreshed feat/muse-glimmer-native (#423 + main fe9b5282) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…SDK base

Only the libs/mlx-swift-lm gitlink conflicted. It now pins 097061cc, mlx-swift-lm
#427 (images) with the refreshed feat/muse-glimmer-native (#423 + #434) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…SDK base

Only the libs/mlx-swift-lm gitlink conflicted. It now pins 5e697d84, mlx-swift-lm
#427 (vision) with the refreshed feat/muse-glimmer-native (#423 + main fe9b5282) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…SDK base

Only the libs/mlx-swift-lm gitlink conflicted. It now pins c7dbf1a0, mlx-swift-lm
#429 (ATEM reference reader) with the refreshed feat/muse-glimmer-native (#423 + #434) merged in.
This branch started at 7b75e0d and did not contain feat/muse-glimmer-30b's
earlier dev merge; this merge brings the whole base in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 15, 2026
…SDK base

Only the libs/mlx-swift-lm gitlink conflicted. It now pins 1d2ba618, mlx-swift-lm
#429 (ATEM reference reader) with the refreshed feat/muse-glimmer-native (#423 + main fe9b5282) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
libs/mlx-swift-lm moves from c1103b8c to cc2be070, the same branch
(feat/muse-glimmer-native, #423) with three commits on top:

- 824db4cf keeps an ATEM value nested past 63 levels as text;
- 31a7ccb2 keeps JSON text nested past 63 levels as text in ToolArgumentNormalization, which
  both ATEM readers call after typing a value;
- cc2be070 formats the new test with swift-format 6.4.4.

Without them, a Muse tool call whose parameter nests about 192 objects or 224 arrays deep
(160 in a debug build) exhausts the 512 KiB cooperative stack when NativeToolStreamRouter
encodes its arguments, and the provider stops with SIGBUS. libs/mlx and libs/mlx-swift are
unchanged.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
…sting bounds

#2149 now reads the tool channel in linear time (e2c60ca) and pins #423 with the nesting
bounds. Only the libs/mlx-swift-lm gitlink conflicted. It now pins 62cfabd5, mlx-swift-lm
#428 (speed) with that #423 (cc2be070) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
…sting bounds

#2149 now reads the tool channel in linear time (e2c60ca) and pins #423 with the nesting
bounds. Only the libs/mlx-swift-lm gitlink conflicted. It now pins 3702459f, mlx-swift-lm
#427 (vision) with that #423 (cc2be070) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
…sting bounds

#2149 now reads the tool channel in linear time (e2c60ca) and pins #423 with the nesting
bounds. Only the libs/mlx-swift-lm gitlink conflicted. It now pins b7672434, mlx-swift-lm
#429 (ATEM reference reader) with that #423 (cc2be070) merged in.
libs/mlx and libs/mlx-swift stay at 72dffa2d and b1c94d29.

Co-Authored-By: Claude <noreply@anthropic.com>
jonathan308 added a commit that referenced this pull request Nov 18, 2026
The suite feeds seeded random and hostile model output, at every
chunking, through:

- the channel splitter;
- the tool frame;
- the SDK's ATEM reference reader and its strict parser;
- the scheduler's forwarding body, under every tool choice.

Each must hold up the way the inbound-depth (#2130), queue-budget
(#2135) and TOML (#2138) fixes were tested. It must not crash, stall,
buffer without bound, leak framing, raise invalidToolPayload or return
a 500. A frame the model gets wrong is the model's error, a 422.

deepNesting and the deep hostile frames need the nesting bounds of
mlx-swift-lm #423 (824db4cf and 31a7ccb2, from d266d4e6 and 7f958c64)
in the pin; this branch pins b7672434, which has them. Without them, a value
nested a few hundred levels deep stops the test process with SIGBUS,
as it would stop a provider.

repeatedStrayCloses took about two minutes in a debug build while the
splitter rescanned the tool body on every stray closing tag; with the
linear splitter of #2149 (e2c60ca) it takes about a second.

Test-only.

Co-Authored-By: Claude <noreply@anthropic.com>
GumbiiDigital added a commit to GumbiiDigital/d-inference that referenced this pull request Dec 3, 2026
…che (replay Layr-Labs#2149)

Replays Layr-Labs#2149 onto dev (82175d9) and pins
libs/mlx-swift-lm to d625d5bde2bd6f181227e858422f1d072d84c6cc
(Layr-Labs/mlx-swift-lm#579, multimodal SDK baseline: Layr-Labs#423, Layr-Labs#427, Layr-Labs#429,
Layr-Labs#430, Layr-Labs#432; Layr-Labs#428 omitted) so every commit in the stack compiles cleanly.

Drops Layr-Labs#2149's MTPAcceptancePolicy.swift edit (superseded by Layr-Labs#2723
universal exact acceptance on dev), regenerates
fixtures/prompt-contract/v1/reasoning_effort_vectors.json (475 -> 504
cases, inserting muse_glimmer at indices 380-408 via
scripts/generate-reasoning-effort-vectors.py), and updates
CachePromptParityTests and MuseGlimmerPolicyTests for dev parity.

This branch had an error being deployed

1 failed and 3 active deployments
Preview – d-inference-console-ui-dev — a83c5dac Deployed Jun 20, 2026 by vercel[bot]
Preview – d-inference — a83c5dac Deployed Jun 20, 2026 by vercel[bot]
Preview – d-inference-landing — a83c5dac Deployed Jun 20, 2026 by vercel[bot]
benchmarks — a83c5dac Deployed Jun 20, 2026 by Gajesh2007 via E2E Benchmarks #1271
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