fix(client-flip): infer cloud mode from API url+key (fleet flip writes no STORAGE_MODE) - #20
Merged
Merged
Conversation
… 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.
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.
Problem (review-flagged)
The machines fleet flip writes exactly two env vars per app —
HASNA_KNOWLEDGE_API_URL+HASNA_KNOWLEDGE_API_KEY— and noSTORAGE_MODE. The@hasna/contractsclient-flip only resolves tocloud-httpwhen 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
resolveKnowledgeCloudStorenow 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 tohttps://knowledge.hasna.xyz/v1/notesvia the bearer client. An explicit storage-mode var always wins (…STORAGE_MODE=localpins local), so the flip stays fully reversible: unset either var -> local.Proof (built bin, live cloud)
add/get/deletehitknowledge.hasna.xyz/v1, each verified independently via the API (create 200 -> delete 404).Bumps to 0.2.80.