Skip to content

fix(client-flip): infer cloud mode from API url+key (fleet flip writes no STORAGE_MODE) - #20

Merged
andrei-hasna merged 1 commit into
mainfrom
fix/client-flip-infer-cloud-mode
Jul 7, 2026
Merged

fix(client-flip): infer cloud mode from API url+key (fleet flip writes no STORAGE_MODE)#20
andrei-hasna merged 1 commit into
mainfrom
fix/client-flip-infer-cloud-mode

Conversation

@andrei-hasna

Copy link
Copy Markdown
Contributor

Problem (review-flagged)

The machines fleet flip writes exactly two env vars per app — HASNA_KNOWLEDGE_API_URL + HASNA_KNOWLEDGE_API_KEY — and no STORAGE_MODE. The @hasna/contracts client-flip only resolves to cloud-http when a storage-mode var is present, so with just the two flip vars set the installed CLI silently kept reading the local db.json even though the flip was applied.

Fix

resolveKnowledgeCloudStore now infers cloud mode when both the API url and API key are set and no explicit storage-mode var is present. Every knowledge-item read/write then routes to https://knowledge.hasna.xyz/v1/notes via the bearer client. An explicit storage-mode var always wins (…STORAGE_MODE=local pins local), so the flip stays fully reversible: unset either var -> local.

Proof (built bin, live cloud)

  • URL+KEY only -> add/get/delete hit knowledge.hasna.xyz/v1, each verified independently via the API (create 200 -> delete 404).
  • Unset -> reads local db.json.
  • Regression tests added (url+key-only trigger; url-only & key-only negatives). Full suite 173/173 green.

Bumps to 0.2.80.

… actually routes to cloud

The machines fleet flip writes exactly two env vars per app
(HASNA_KNOWLEDGE_API_URL + HASNA_KNOWLEDGE_API_KEY) and no STORAGE_MODE.
The @hasna/contracts client-flip only resolves to cloud-http when a storage
mode var is present, so with just the two flip vars set the installed CLI
silently kept reading the local db.json — the exact defect flagged in review.

resolveKnowledgeCloudStore now infers cloud mode when BOTH the API url and
API key are set and no explicit storage-mode var is present, so every knowledge
item read/write routes to https://knowledge.hasna.xyz/v1/notes via the bearer
client. An explicit storage-mode var always wins (…STORAGE_MODE=local pins
local), keeping the flip fully reversible: unset either var -> local.

Adds regression tests for the url+key-only trigger and the url-only / key-only
negatives. Rebuilds the CLI + MCP bins. Bumps to 0.2.80.
@andrei-hasna
andrei-hasna merged commit 63b2ef7 into main Jul 7, 2026
0 of 7 checks passed
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