Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "vendor/footnote"]
path = vendor/footnote
url = https://github.com/mieweb/melvil-artipod-footnote
branch = main
3 changes: 2 additions & 1 deletion packages/cloud-local/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"test": "node --test"
},
"dependencies": {
"@hono/node-server": "^1.13.0"
"@hono/node-server": "^1.13.0",
"@mieweb/footnote": "link:../../vendor/footnote"
},
"optionalDependencies": {
"better-sqlite3": "^11.0.0",
Expand Down
12 changes: 12 additions & 0 deletions packages/cloud-local/src/registry.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createInprocQueue } from './adapters/queue-inproc.mjs';
import { createInprocNamespace } from './adapters/durable-inproc.mjs';
import { createAiBackend } from './adapters/ai-multi.mjs';
import { createUnsupportedBinding } from './adapters/unsupported.mjs';
import { createLocalIndex } from '@mieweb/footnote/vectorize';

/**
* Driver registry — the single extension point for the portability layer.
Expand Down Expand Up @@ -70,6 +71,17 @@ registerDriver('sqlite-vec', ({ cfg, resolvePath }) =>
createSqliteVecIndex(resolvePath(cfg.path), { dim: cfg.dim ?? 768 }),
);

// FOOTNOTE (artipod) — the richer Vectorize store: hybrid + FTS + assertion-aware
// retrieval, same CloudVectorIndex contract. See mieweb/melvil-artipod-footnote.
registerDriver('footnote', ({ cfg, resolvePath }) =>
createLocalIndex({
name: cfg.name ?? 'index',
dimensions: cfg.dim ?? 768,
metric: cfg.metric ?? 'cosine',
dbPath: cfg.path ? resolvePath(cfg.path) : undefined,
}),
);

registerDriver('fs', ({ cfg, resolvePath }) => createFsBucket(resolvePath(cfg.path)));

registerDriver('memory', () => createMemoryKV());
Expand Down
53 changes: 53 additions & 0 deletions packages/cloud-local/test/conformance.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import {
createSqliteD1,
createSqliteVecIndex,
createAiBackend,
createCloudEnv,
settleEnv,
} from '../src/index.mjs';

function tmp(prefix) {
Expand All @@ -46,6 +48,15 @@ async function hasSqliteVec() {
}
}

async function hasFootnote() {
try {
await import('@mieweb/footnote/vectorize');
return true;
} catch {
return false;
}
}

// --- KV contract ---------------------------------------------------------
test('KV (memory): get/put/delete + TTL + list prefix', async () => {
const kv = createMemoryKV();
Expand Down Expand Up @@ -154,6 +165,48 @@ test('Vectorize (sqlite-vec): upsert/query/filter/getByIds/deleteByIds', async (
}
});

// Same Vectorize contract, but driven through the FOOTNOTE driver exactly as a
// `mieweb.jsonc` binding of `{ driver: 'footnote' }` would be — this covers the
// registerDriver('footnote', …) resolution path in registry.mjs, not just the
// footnote package in isolation.
test('Vectorize (footnote driver): resolves via createCloudEnv + honors contract', async (t) => {
if (!(await hasFootnote())) return t.skip('@mieweb/footnote not linked');
const dir = tmp('mwc-footnote-');
try {
const targetConfig = {
bindings: {
VECTOR: { driver: 'footnote', name: 'idx', dim: 4, metric: 'cosine', path: 'idx.sqlite' },
},
};
const { env } = createCloudEnv({ targetConfig, root: dir, target: 'local' });
await settleEnv(env); // createLocalIndex constructs asynchronously
const idx = env.VECTOR;
assert.ok(idx, 'VECTOR binding resolved to a footnote index');

await idx.upsert([
{ id: 'a', values: [1, 0, 0, 0], metadata: { org: 'o1', kind: 'doc' } },
{ id: 'b', values: [0, 1, 0, 0], metadata: { org: 'o1', kind: 'call' } },
{ id: 'c', values: [0.9, 0.1, 0, 0], metadata: { org: 'o2', kind: 'doc' } },
]);

const top = await idx.query([1, 0, 0, 0], { topK: 2, returnMetadata: true });
assert.equal(top.matches[0].id, 'a');
assert.ok(top.matches[0].score > top.matches[1].score);

const filtered = await idx.query([1, 0, 0, 0], { topK: 5, filter: { org: { $eq: 'o1' } } });
assert.deepEqual(filtered.matches.map((m) => m.id).sort(), ['a', 'b']);

const inFilter = await idx.query([1, 0, 0, 0], { topK: 5, filter: { kind: { $in: ['call'] } } });
assert.deepEqual(inFilter.matches.map((m) => m.id), ['b']);

await idx.deleteByIds(['b']);
const afterDelete = await idx.query([0, 1, 0, 0], { topK: 5 });
assert.ok(!afterDelete.matches.some((m) => m.id === 'b'));
} finally {
rmSync(dir, { recursive: true, force: true });
}
});

// --- AI contract ---------------------------------------------------------
test('AI (ollama): run({text}) embeddings + toMarkdown passthrough', async () => {
const ai = createAiBackend({
Expand Down
12 changes: 11 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vendor/footnote
Submodule footnote added at 6ab786