Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

fix(proxy): make the subscription plane reachable again after cloud routing (#2928)

Dragan Spiridonov6d58837f4f20
diff --git a/v3/@claude-flow/cli/__tests__/proxy-config-command.test.ts b/v3/@claude-flow/cli/__tests__/proxy-config-command.test.ts
index de54ed3026..5742009ab8 100644
--- a/v3/@claude-flow/cli/__tests__/proxy-config-command.test.ts
+++ b/v3/@claude-flow/cli/__tests__/proxy-config-command.test.ts
@@ -259,4 +259,163 @@ describe('cloud routing disclosure', () => {
expect(text).toContain('instead of using the model');
expect(text).toContain('ruflo proxy config --routing-mode');
});
+
+ /**
+ * "Disable anytime: --local-only" was a single command for a choice with
+ * two destinations, and the one it named silently drops the user's own
+ * subscription. The disclosure must offer both.
+ */
+ it('offers both ways off the cloud plane, not just the local one', async () => {
+ const text = await disclosureShownOnUnconfirmedCloud();
+
+ expect(text).toContain('ruflo proxy config --passthrough');
+ expect(text).toContain('ruflo proxy config --local-only');
+ });
+});
+
+/**
+ * `--passthrough`. Turning cloud routing OFF is a choice of destination:
+ * `local` is the user's own backend, `passthrough` is their own Claude
+ * subscription (meta-proxy's `DataPlane::Passthrough`, and its own default).
+ * Before this, `--local-only` was the only exit, so a user who started on
+ * passthrough, enabled cloud, and turned it back off silently lost their
+ * subscription β€” and with it automatic quota failover, which meta-proxy
+ * (`routing.rs`) only applies while the plane is passthrough.
+ */
+describe('proxy config --passthrough', () => {
+ const configPath = () => path.join(stateDir, 'proxy-config.toml');
+ const planeInFile = () => fs.readFileSync(configPath(), 'utf-8').match(/default_data_plane = "([^"]*)"/)?.[1];
+
+ it('writes default_data_plane = "passthrough" and revokes cloud-routing consent', async () => {
+ const configSub = await getConfigSub();
+ await configSub.action!(ctxWithFlags({ cloud: true, yes: true }));
+
+ const result = await configSub.action!(ctxWithFlags({ passthrough: true }));
+
+ expect(result?.success).toBe(true);
+ expect(planeInFile()).toBe('passthrough');
+
+ const { hasConsent } = await import('../src/funnel/index.js');
+ expect(hasConsent('cloud-routing')).toBe(false);
+ });
+
+ /** The defect, stated as a round trip: leave passthrough, come back to it. */
+ it('restores the subscription plane after a cloud round trip', async () => {
+ fs.writeFileSync(configPath(), 'default_data_plane = "passthrough"\n');
+ const configSub = await getConfigSub();
+
+ await configSub.action!(ctxWithFlags({ cloud: true, yes: true }));
+ expect(planeInFile()).toBe('cloud');
+ await configSub.action!(ctxWithFlags({ passthrough: true }));
+
+ expect(planeInFile()).toBe('passthrough');
+ });
+
+ it('--local-only still means the local backend, unchanged', async () => {
+ const configSub = await getConfigSub();
+
+ await configSub.action!(ctxWithFlags({ localOnly: true }));
+
+ expect(planeInFile()).toBe('local');
+ });
+
+ it('refuses more than one plane flag rather than silently picking one', async () => {
+ const configSub = await getConfigSub();
+
+ for (const flags of [
+ { cloud: true, passthrough: true },
+ { localOnly: true, passthrough: true },
+ { cloud: true, localOnly: true, passthrough: true },
+ ]) {
+ const result = await configSub.action!(ctxWithFlags(flags));
+ expect(result?.success, JSON.stringify(flags)).toBe(false);
+ }
+ expect(fs.existsSync(configPath())).toBe(false);
+ });
+
+ it('refuses to pin a tier while --passthrough is turning the cloud plane off', async () => {
+ const configSub = await getConfigSub();
+
+ const result = await configSub.action!(ctxWithFlags({ passthrough: true, routingMode: 'high' }));
+
+ expect(result?.success).toBe(false);
+ expect(fs.existsSync(configPath())).toBe(false);
+ });
+
+ it('reports passthrough distinctly from local, not as one "cloud is off" state', async () => {
+ const configSub = await getConfigSub();
+
+ await configSub.action!(ctxWithFlags({ passthrough: true }));
+ const onPassthrough = await configSub.action!(ctxWithFlags({}));
+ await configSub.action!(ctxWithFlags({ localOnly: true }));
+ const onLocal = await configSub.action!(ctxWithFlags({}));
+
+ expect((onPassthrough?.data as { plane?: string })?.plane).toBe('passthrough');
+ expect((onLocal?.data as { plane?: string })?.plane).toBe('local');
+ });
+
+ it('preserves unrelated lines when writing the plane', async () => {
+ fs.writeFileSync(configPath(), 'bind = "127.0.0.1:11435"\nrouting_mode = "high"\n');
+ const configSub = await getConfigSub();
+
+ await configSub.action!(ctxWithFlags({ passthrough: true }));
+
+ const raw = fs.readFileSync(configPath(), 'utf-8');
+ expect(raw).toContain('bind = "127.0.0.1:11435"');
+ expect(raw).toContain('routing_mode = "high"');
+ expect(raw).toContain('default_data_plane = "passthrough"');
+ });
+});
+
+describe('plane guidance', () => {
+ async function linesFrom(flags: Record<string, unknown>): Promise<string> {
+ const lines: string[] = [];
+ const { output } = await import('../src/output.js');
+ const write = vi.spyOn(output, 'writeln').mockImplementation((line?: string) => {
+ lines.push(String(line ?? ''));
+ });
+ const success = vi.spyOn(output, 'printSuccess').mockImplementation((line?: string) => {
+ lines.push(String(line ?? ''));
+ });
+ try {
+ const configSub = await getConfigSub();
+ await configSub.action!(ctxWithFlags(flags));
+ } finally {
+ write.mockRestore();
+ success.mockRestore();
+ }
+ return lines.join('\n');
+ }
+
+ it('names the plane being left and how to restore it when enabling cloud', async () => {
+ fs.writeFileSync(path.join(stateDir, 'proxy-config.toml'), 'default_data_plane = "passthrough"\n');
+
+ const text = await linesFrom({ cloud: true, yes: true });
+
+ expect(text).toContain('Previous plane: passthrough');
+ expect(text).toContain('ruflo proxy config --passthrough');
+ });
+
+ it('warns that --local-only does not use the Claude subscription', async () => {
+ const text = await linesFrom({ localOnly: true });
+
+ expect(text).toContain('NOT used on this plane');
+ expect(text).toContain('ruflo proxy config --passthrough');
+ });
+
+ it('does not add that warning when landing on passthrough', async () => {
+ const text = await linesFrom({ passthrough: true });
+
+ expect(text).not.toContain('NOT used on this plane');
+ });
+
+ /** Sitting on `local` opts you out of ADR-321 failover; nothing else says so. */
+ it('flags that automatic quota failover does not apply while on local', async () => {
+ const configSub = await getConfigSub();
+ await configSub.action!(ctxWithFlags({ localOnly: true }));
+
+ const text = await linesFrom({});
+
+ expect(text).toContain('automatic quota failover (ADR-321) applies only on passthrough');
+ });
});
diff --git a/v3/@claude-flow/cli/src/commands/proxy.ts b/v3/@claude-flow/cli/src/commands/proxy.ts
index 53a2b625de..be282ad0e3 100644
--- a/v3/@claude-flow/cli/src/commands/proxy.ts
+++ b/v3/@claude-flow/cli/src/commands/proxy.ts
@@ -93,10 +93,40 @@ function readDataPlane(): string {
return match ? match[1] : 'passthrough'; // matches the Rust struct's own default
}
-function writeDataPlane(plane: 'local' | 'cloud'): void {
+function writeDataPlane(plane: 'local' | 'cloud' | 'passthrough'): void {
writeConfigLine('default_data_plane', `"${plane}"`);
}
+/**
+ * How to get back to a given plane, for "restore what you had" guidance.
+ * `sponsored` is ADR-313's own consent flow and is deliberately absent β€” this
+ * command must not offer a one-flag route into someone else's consent gate.
+ */
+const PLANE_RESTORE_COMMAND: Record<string, string> = {
+ passthrough: 'ruflo proxy config --passthrough',
+ local: 'ruflo proxy config --local-only',
+};
+
+/**
+ * One line describing a plane in the terms that matter β€” who serves the
+ * request. Kept together so the no-flag report and the restore hints cannot
+ * describe the same plane two different ways.
+ */
+function describePlane(plane: string): string {
+ switch (plane) {
+ case 'cloud':
+ return 'Cloud routing is ON β€” cloud-tier requests go to api.cognitum.one.';
+ case 'passthrough':
+ return 'Passthrough β€” requests go to your own Claude subscription. Prompts do not go to Cognitum.';
+ case 'local':
+ return 'Local-only β€” requests go to your own backend (Ollama/vLLM/SGLang) and never leave this machine.';
+ case 'sponsored':
+ return "Sponsored β€” requests go to Cognitum's sponsored capacity (ADR-313).";
+ default:
+ return `Unrecognized plane "${plane}" β€” meta-proxy will fall back to its own default (passthrough).`;
+ }
+}
+
/**
* `routing_mode` β€” how the Cloud plane picks a tier (meta-proxy ADR-321
* rev-2). Values match the Rust `RoutingMode` enum (`src/config.rs`, also
@@ -152,7 +182,9 @@ const CLOUD_ROUTING_DISCLOSURE = [
'',
'Requests routed to local backends never leave this machine.',
'',
- 'Disable anytime: ruflo proxy config --local-only',
+ 'Turning it off is a choice of where to go back to, not one command:',
+ ' ruflo proxy config --passthrough Your own Claude subscription',
+ ' ruflo proxy config --local-only Your own local backend',
].join('\n');
const configSub: Command = {
@@ -160,7 +192,13 @@ const configSub: Command = {
description: 'Toggle cloud routing and its tier selection (ADR-304/321) β€” local backends only by default',
options: [
{ name: 'cloud', description: 'Enable cloud routing (requires cloud-routing consent)', type: 'boolean', default: false },
- { name: 'local-only', description: 'Disable cloud routing, revert to local-only routing', type: 'boolean', default: false },
+ { name: 'local-only', description: 'Disable cloud routing; route to your own local backend', type: 'boolean', default: false },
+ {
+ name: 'passthrough',
+ description: "Disable cloud routing; route to your own Claude subscription (meta-proxy's own default)",
+ type: 'boolean',
+ default: false,
+ },
{
name: 'routing-mode',
description: `How the cloud plane picks a tier: ${ROUTING_MODES.join(' | ')} (default: auto)`,
@@ -171,11 +209,17 @@ const configSub: Command = {
action: async (ctx): Promise<CommandResult> => {
const wantCloud = Boolean(ctx.flags.cloud);
const wantLocalOnly = Boolean(ctx.flags.localOnly ?? ctx.flags['local-only']);
+ const wantPassthrough = Boolean(ctx.flags.passthrough);
const rawRoutingMode = ctx.flags.routingMode ?? ctx.flags['routing-mode'];
const wantRoutingMode = typeof rawRoutingMode === 'string' ? rawRoutingMode : undefined;
- if (wantCloud && wantLocalOnly) {
- output.printError('Pass either --cloud or --local-only, not both.');
+ const planeFlags = [
+ wantCloud && '--cloud',
+ wantLocalOnly && '--local-only',
+ wantPassthrough && '--passthrough',
+ ].filter(Boolean) as string[];
+ if (planeFlags.length > 1) {
+ output.printError(`Pass one plane at a time β€” got ${planeFlags.join(' and ')}.`);
return { success: false, exitCode: 1 };
}
@@ -187,24 +231,21 @@ const configSub: Command = {
}
const routingMode = wantRoutingMode as RoutingMode | undefined;
- // A tier only means anything on the Cloud plane, and --local-only leaves
+ // A tier only means anything on the Cloud plane, and these flags leave
// it. Writing both would record a preference the same command just made
// unreachable, so say so instead of silently picking one.
- if (routingMode && wantLocalOnly) {
+ const leavingCloud = wantLocalOnly || wantPassthrough;
+ if (routingMode && leavingCloud) {
output.printError(
- '--routing-mode only governs the cloud plane, which --local-only turns off. Pass one or the other.',
+ `--routing-mode only governs the cloud plane, which ${planeFlags[0]} turns off. Pass one or the other.`,
);
return { success: false, exitCode: 1 };
}
- if (!wantCloud && !wantLocalOnly && !routingMode) {
+ if (!wantCloud && !leavingCloud && !routingMode) {
const plane = readDataPlane();
output.writeln(`Current data plane: ${plane}`);
- output.writeln(
- plane === 'cloud'
- ? 'Cloud routing is ON β€” cloud-tier requests go to api.cognitum.one.'
- : 'Cloud routing is OFF β€” requests never leave this machine (or use your own Claude subscription on Passthrough).',
- );
+ output.writeln(` ${describePlane(plane)}`);
const mode = readRoutingMode();
output.writeln(
mode === 'auto'
@@ -212,6 +253,14 @@ const configSub: Command = {
: ` Tier selection: pinned to ${mode}.`,
);
if (plane !== 'cloud') output.writeln(' (Tier selection applies only while cloud routing is ON.)');
+ // meta-proxy routing.rs gates automatic quota failover on the plane
+ // being Passthrough β€” it is the only plane that sees Anthropic's own
+ // rate-limit headers. Worth saying, because nothing else reveals that
+ // sitting on `local` silently opts you out of ADR-321 entirely.
+ if (plane === 'local') {
+ output.writeln(' Note: automatic quota failover (ADR-321) applies only on passthrough.');
+ output.writeln(' Use your Claude subscription instead: ruflo proxy config --passthrough');
+ }
return { success: true, data: { plane, routingMode: mode } };
}
@@ -233,14 +282,26 @@ const configSub: Command = {
return { success: true, data: { routingMode } };
}
- if (wantLocalOnly) {
- writeDataPlane('local');
- revokeConsent('cloud-routing', 'proxy-config-local-only');
- output.printSuccess('Cloud routing disabled β€” reverted to local-only routing.');
- return { success: true, data: { plane: 'local' } };
+ if (leavingCloud) {
+ const plane = wantPassthrough ? 'passthrough' : 'local';
+ writeDataPlane(plane);
+ revokeConsent('cloud-routing', wantPassthrough ? 'proxy-config-passthrough' : 'proxy-config-local-only');
+ output.printSuccess(`Cloud routing disabled β€” now on ${plane}.`);
+ output.writeln(` ${describePlane(plane)}`);
+ // Naming the other option here is the point: "disable cloud" has two
+ // destinations, and the one you land on decides whether your own
+ // subscription is used at all.
+ if (plane === 'local') {
+ output.writeln(' Your own Claude subscription is NOT used on this plane. To use it instead:');
+ output.writeln(' ruflo proxy config --passthrough');
+ }
+ return { success: true, data: { plane } };
}
- // wantCloud
+ // wantCloud. Read the plane being left BEFORE overwriting it β€” this is
+ // the only moment ruflo knows where the user was, and "how do I get back"
+ // is otherwise unanswerable from the config file afterwards.
+ const previousPlane = readDataPlane();
if (!hasConsent('cloud-routing')) {
output.writeln(CLOUD_ROUTING_DISCLOSURE);
output.writeln('');
@@ -263,8 +324,14 @@ const configSub: Command = {
: ` Tier selection: pinned to ${effectiveMode}.`,
);
output.writeln(' Requests routed to local backends still never leave this machine.');
- output.writeln(' Disable anytime: ruflo proxy config --local-only');
- return { success: true, data: { plane: 'cloud', routingMode: effectiveMode } };
+ const restore = previousPlane === 'cloud' ? undefined : PLANE_RESTORE_COMMAND[previousPlane];
+ if (restore) {
+ output.writeln(` Previous plane: ${previousPlane}. Restore it with:`);
+ output.writeln(` ${restore}`);
+ } else {
+ output.writeln(' Turn it off with: ruflo proxy config --passthrough (or --local-only)');
+ }
+ return { success: true, data: { plane: 'cloud', routingMode: effectiveMode, previousPlane } };
},
};
@@ -521,6 +588,7 @@ export const proxyCommand: Command = {
{ command: 'ruflo proxy status', description: 'Show install + process status' },
{ command: 'ruflo proxy config --cloud --yes', description: 'Enable cloud routing (ADR-304)' },
{ command: 'ruflo proxy config --routing-mode high', description: 'Pin the cloud tier instead of auto (ADR-321)' },
+ { command: 'ruflo proxy config --passthrough', description: 'Turn cloud routing off, back to your Claude subscription' },
{ command: 'ruflo proxy config --local-only', description: 'Revert to local-only routing' },
{ command: 'ruflo proxy sponsor-status', description: 'Show current sponsored-mode state' },
{ command: 'ruflo proxy sponsor-enable --yes', description: 'Opt into sponsored downtime capacity' },
diff --git a/v3/docs/adr/ADR-304-local-meta-llm-proxy.md b/v3/docs/adr/ADR-304-local-meta-llm-proxy.md
index 58df99c310..34f35f3d56 100644
--- a/v3/docs/adr/ADR-304-local-meta-llm-proxy.md
+++ b/v3/docs/adr/ADR-304-local-meta-llm-proxy.md
@@ -63,7 +63,7 @@ obtains credentials for proxy operation.
The default answer is No. The exact wording lives in `CLOUD_ROUTING_DISCLOSURE` (`src/commands/proxy.ts`) and is asserted by `proxy-config-command.test.ts`; it is deliberately not transcribed here, because the previous copy in this ADR fell behind the shipped text and a reader could not tell which one was real.
- **Visible at runtime.** `ruflo proxy status` and every request receipt state the data plane used (`local` vs `cloud:<provider>`), so the user can verify where any given prompt went.
-- Cloud routing can be disabled at any time (`ruflo proxy config --local-only`), reverting to a purely local multi-backend router and revoking the `cloud-routing` consent receipt.
+- Cloud routing can be disabled at any time, revoking the `cloud-routing` consent receipt. **Disabling is a choice of destination, not one command**: `ruflo proxy config --local-only` goes to a purely local multi-backend router, `ruflo proxy config --passthrough` goes to the user's own Claude subscription. See the 2026-08-05 addendum β€” treating these as one state is how a user could lose their subscription by turning cloud routing off.
## Relationship to the metallm dev-bridge
@@ -111,9 +111,10 @@ against the real v0.1.0 binary: `default_data_plane = "Local"` (PascalCase, the
silently fell back to the default plane (Passthrough) rather than erroring β€” consistent with this
ADR's own "a malformed config must never crash the proxy" design, but a real trap for anyone
guessing the casing from the Rust variant names alone. `"local"` (lowercase) took a visibly
-different code path in the same test. Only `"local"`/`"cloud"` are written by this command;
-`"sponsored"` stays owned by ADR-313's own `sponsor-enable`/`sponsor-disable`, and `"passthrough"`
-is never written (the proxy's own untouched default).
+different code path in the same test. At the time only `"local"`/`"cloud"` were written by this
+command; `"sponsored"` stays owned by ADR-313's own `sponsor-enable`/`sponsor-disable`.
+**`"passthrough"` is now written too, by `--passthrough` β€” see the 2026-08-05 restore addendum;
+the original "never written (the proxy's own untouched default)" is superseded.**
`ruflo proxy config` (no flags) reports the current plane by reading the same file, defaulting to
`"passthrough"` (matching the Rust struct's own default) when no config file exists yet.
@@ -162,3 +163,48 @@ unconfirmed `--cloud` still writes nothing at all.
cap. Sponsored has `sponsored_daily_cap_usd`; Cloud has no proxy-side equivalent. #43 records the
cap amount and reset semantics as a product decision that must not be guessed, so the disclosure
makes no claim about caps in either direction.
+
+## Addendum (2026-08-05) β€” turning cloud routing off has two destinations, and only one was reachable
+
+`--local-only` was the sole exit from the cloud plane, and it writes
+`default_data_plane = "local"`. `local` is the user's own Ollama/vLLM/SGLang backend.
+`passthrough` β€” meta-proxy's own default, and the plane that uses the user's own Claude
+subscription β€” was unreachable from this command by design ("`passthrough` is never written",
+above).
+
+That made the advertised undo wrong. A user on `passthrough` who followed our own disclosure
+("Disable anytime: `ruflo proxy config --local-only`") landed on a **third** state they never chose,
+pointed at a local backend that may not be installed. Two consequences, neither visible:
+
+1. **Their Claude subscription stops being used at all.** This is precisely the harm
+ cognitum-one/meta-proxy#51 closed on the login path β€” *"Combining those decisions silently
+ switches a user away from Passthrough β€” their own Claude subscription β€” to api.cognitum.one"* β€”
+ arriving here through a different door.
+2. **Automatic quota failover silently stops applying.** meta-proxy gates it on the plane
+ (`src/routing.rs`: `automatic_eligible = cfg.default_data_plane == DataPlane::Passthrough`),
+ because Passthrough is the only plane that sees Anthropic's own rate-limit headers (ADR-320). A
+ user parked on `local` is opted out of ADR-321 entirely and nothing tells them.
+
+The command's own no-flag report papered over the distinction, printing one line β€”
+*"Cloud routing is OFF β€” requests never leave this machine (or use your own Claude subscription on
+Passthrough)"* β€” for two planes that behave differently.
+
+**Decision.** `--local-only` keeps its meaning exactly (the flag name and this ADR both promise a
+local backend; changing its target silently would be a second surprise). Instead:
+
+- **`ruflo proxy config --passthrough` is added**, writing `default_data_plane = "passthrough"` and
+ revoking `cloud-routing` consent the same way `--local-only` does. The plane is now reachable.
+- **The disclosure names both exits** rather than presenting `--local-only` as *the* undo.
+- **`--cloud` reads the plane it is leaving before overwriting it** and prints the exact command to
+ restore it. That read is the only moment ruflo knows where the user was; nothing in the config
+ file answers it afterwards, and this avoids persisting a "previous plane" that could go stale
+ against a hand-edited TOML.
+- **`--local-only` says what it did**, including that the Claude subscription is not used on that
+ plane and how to choose it instead.
+- **The no-flag report describes each plane distinctly**, and calls out the ADR-321 failover
+ consequence while on `local`.
+- **Plane flags are mutually exclusive** β€” passing more than one is refused rather than resolved by
+ precedence, since any precedence order would silently discard something the user asked for.
+
+This does not change any default. A user who never runs the command is on `passthrough`, exactly as
+before.