Skip to content

cloud-backed knowledge store: vendored storage kit + PURE REMOTE cloud mode - #12

Merged
andrei-hasna merged 4 commits into
mainfrom
oss-cloud-runtime/knowledge-cloud-storage-kit
Jul 6, 2026
Merged

cloud-backed knowledge store: vendored storage kit + PURE REMOTE cloud mode#12
andrei-hasna merged 4 commits into
mainfrom
oss-cloud-runtime/knowledge-cloud-storage-kit

Conversation

@andrei-hasna

Copy link
Copy Markdown
Contributor

First cloud tenant wiring for @hasna/knowledge (todos 4927ea2d, LANE knowledge-cloud).

What

  • Vendored storage kit (src/generated/storage-kit/) via contracts vendor-kit (kitVersion 0.4.0): correct RDS TLS, pool factory, typed query wrapper with the restored get(), migration ledger (sha256 checksum + drift/downgrade guards), health probes. contracts vendor-kit --check passes.
  • Refactored all cloud pg access through the kit: PgAdapterAsync now builds its pool/TLS via the kit (replacing the hand-rolled rejectUnauthorized:false shim) and exposes the restored single-row get().
  • A1 PURE REMOTE mode contract: StorageMode is now local|cloud; deprecated aliases (remote/hybrid/self_hosted) normalize to cloud; a DATABASE_URL alone no longer implies a hybrid runtime (cloud must be requested via HASNA_KNOWLEDGE_STORAGE_MODE=cloud).
  • Migration runner scripts/apply-cloud-migrations.mjs applies the schema through the kit's MigrationLedger. Proven end-to-end against a throwaway Postgres 16: dry-run → apply (24 tables, 60 ledger rows) → idempotent re-apply (pending: []) → get() + checkHealth OK.
  • Contract + compose: hasna.contract.json (cli-with-store, v1) — repo-conformance passes; dev docker-compose.yml. Externalized @hasna/contracts in the build so the guard-pattern strings no longer leak into artifacts.

Tests / gates

  • bun test: 154/154 green (one machines-topology test is a shared-state flake; passes in isolation and on rerun).
  • bun run build (prepublishOnly): exit 0.
  • Secrets scan on staged diff: clean (no real credentials; only doc/test placeholders).

Out of scope / follow-ups

  • RDS migration is PARTIAL: the shared RDS is not reachable from this machine (router pending) and no per-app hasna/oss/knowledge/database-url DSN secret exists yet. Run scripts/apply-cloud-migrations.mjs once the router lands and the secret is created.
  • One-time data migration is PARTIAL: local catalog exported (48 records) to ~/.hasna/knowledge/migration-exports/; cloud load + local-sqlite .bak rename deferred until the cloud DB is reachable (renaming now would break local operation before cloud is populated).
  • CLI command-layer runtime routing to pg (store.ts/knowledge-db.ts) is a larger follow-up; this PR delivers the sanctioned pg-access layer + migration path per the task's file scope.

Depends on @hasna/contracts kit PRs (#2 contract-v1, #3 kit-codegen) reaching main/npm; kit is vendored so this repo has no runtime dep on it.

… in build

Stamp the canonical PURE REMOTE Postgres storage kit into
src/generated/storage-kit via 'contracts vendor-kit' (kitVersion 0.4.0):
correct RDS TLS, pool factory, typed query wrapper with the restored get(),
migration ledger with checksum drift/downgrade guards, and health probes.

Externalize @hasna/contracts in the bun build (alongside pg/machines) so the
package's own no-cloud guard pattern strings no longer leak into the bundled
CLI artifacts and repo-conformance passes.
Rewrite PgAdapterAsync to build its pool/TLS via the kit (replacing the
hand-rolled rejectUnauthorized:false shim) and restore the dropped single-row
get() helper. Adopt the A1 PURE REMOTE mode contract: StorageMode is now
local|cloud, deprecated aliases (remote/hybrid/self_hosted) normalize to cloud,
and a DATABASE_URL alone no longer implies a hybrid runtime. Add
createKnowledgeCloudClient plus scripts/apply-cloud-migrations.mjs, which applies
the schema through the kit's MigrationLedger (proven idempotent against pg16).
Declare the cli-with-store service contract (v1, kitVersion 0.4.0, canonical
HASNA_KNOWLEDGE_ env prefix and hasna/oss/knowledge/database-url secret ref);
repo-conformance passes. Add a throwaway Postgres compose for exercising cloud
mode locally, and ignore the scoped .hasna/ workspace.
@andrei-hasna
andrei-hasna force-pushed the oss-cloud-runtime/knowledge-cloud-storage-kit branch 2 times, most recently from f514a9f to 3140cf8 Compare July 6, 2026 10:49
@andrei-hasna
andrei-hasna force-pushed the oss-cloud-runtime/knowledge-cloud-storage-kit branch from 3140cf8 to ae708d8 Compare July 6, 2026 10:53
@andrei-hasna
andrei-hasna merged commit 9f54336 into main Jul 6, 2026
6 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