Files
splinter/tests/test_memory.c
T
Konrad fb523c7a2c splinter: skills on demand, memory per user, streaming in the gateway
Skills: ~/.splinter/skills plus any skills_dir from the config. Nothing is
preloaded and the system prompt does not grow - the model asks:
skill_search {query} returns names, one-line descriptions and paths;
skill_load {name} returns the file. Both read-only. A miss says what exists
instead of answering with silence.

Memory: memory_search and memory_add against mem0's REST API. Every request
carries user_id, taken from the account the process runs as ($USER, else the
passwd entry) - deliberately not a config key, because a setting is a thing to
forget and the process already knows who it is. A memory written by root is
invisible to lotherk.

Gateway: it ran without a stream callback, so a provider that only speaks SSE
answered with a stream the non-streaming reader could not parse. It now passes a
no-op callback - nobody to stream to, but the transport takes the streaming path.

tests: test_skills (search, directory form, miss, load, unknown name) and
test_memory (user id from environment and fallback).
2026-11-08 13:44:32 +00:00

40 lines
902 B
C

/*
* splinter -- memory scoping.
*
* The one thing that must never break: the user id. Every request carries it,
* and it comes from who is running - not from a setting someone can forget.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "splinter.h"
#include "memory.h"
static int failures;
#define CHECK(c) do { if (!(c)) { fprintf(stderr, "FAIL %s:%d: %s\n", \
__FILE__, __LINE__, #c); failures++; } } while (0)
int
main(void)
{
const char *user;
/* from the environment */
CHECK(setenv("USER", "lotherk", 1) == 0);
user = sp_memory_user();
CHECK(user != NULL);
CHECK(strcmp(user, "lotherk") == 0);
/* without USER it falls back to the passwd entry, never to empty */
CHECK(unsetenv("USER") == 0);
user = sp_memory_user();
CHECK(user != NULL);
CHECK(strlen(user) > 0);
if (failures == 0)
printf("test_memory: ok\n");
return failures == 0 ? 0 : 1;
}