Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Add local Postgres store test script and package.json workflow rule.

debajyoti-truefoundry17c1245bb442
diff --git a/AGENTS.md b/AGENTS.md
index 36c1dcad8..0cb196826 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -1,3 +1,4 @@
+- Workspace tasks MUST use `package.json` scripts; add a script when a missing workflow is repeatable like the existing commands, not ad hoc commands.
- Changes to types or schemas MUST keep `packages/harness`, `packages/frontend`, `packages/server`, and `patches` synchronized; they MUST NOT update only one affected layer.
- TypeScript code MUST NOT use assertion escapes such as `as T`, `as unknown as T`, non-null `!`, or `as never` to silence type errors; implementations MUST use sound contracts, guards, or corrected types.
- When catching an error and throwing another, the new error MUST set `{ cause: caught }` so the original failure is preserved for logs and debugging.
diff --git a/package.json b/package.json
index eba747906..ff9003fd9 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md}\" --cache --error-on-unmatched-pattern --config .prettierrc",
"format:fix": "prettier --write \"**/*.{js,jsx,ts,tsx,json,md}\" --cache --config .prettierrc",
"test": "pnpm --filter @truefoundry/utils test && pnpm --filter @truefoundry/server test && pnpm --filter frontend test",
+ "test:store:local": "bash scripts/test-store-with-postgres.sh",
"dev:server": "pnpm --filter @truefoundry/server dev",
"dev:frontend": "pnpm --filter frontend dev",
"ui:shot": "node ui-shots/shot.mjs",
diff --git a/scripts/test-store-with-postgres.sh b/scripts/test-store-with-postgres.sh
new file mode 100755
index 000000000..14f651b36
--- /dev/null
+++ b/scripts/test-store-with-postgres.sh
@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+# Starts an ephemeral Postgres container (same defaults as CI) and runs the
+# session-store contract tests. The container is removed on exit.
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+cd "$ROOT"
+
+IMAGE="${POSTGRES_IMAGE:-postgres:17-alpine}"
+PORT="${POSTGRES_PORT:-55432}"
+PGUSER="${POSTGRES_USER:-proto}"
+PGPASSWORD="${POSTGRES_PASSWORD:-proto}"
+PGDATABASE="${POSTGRES_DB:-proto}"
+URL="postgres://${PGUSER}:${PGPASSWORD}@localhost:${PORT}/${PGDATABASE}"
+CONTAINER="harness-store-test-pg-$$"
+STARTED_CONTAINER=0
+WAIT_SECONDS="${POSTGRES_WAIT_SECONDS:-60}"
+
+cleanup() {
+ if [[ "$STARTED_CONTAINER" -eq 1 ]]; then
+ docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
+ fi
+}
+trap cleanup EXIT INT TERM
+
+if ! command -v docker >/dev/null 2>&1; then
+ echo "error: docker is required to run store tests locally" >&2
+ exit 1
+fi
+
+echo "Starting ephemeral Postgres ($IMAGE) on localhost:${PORT}..."
+if ! docker run -d --name "$CONTAINER" \
+ -e "POSTGRES_USER=${PGUSER}" \
+ -e "POSTGRES_PASSWORD=${PGPASSWORD}" \
+ -e "POSTGRES_DB=${PGDATABASE}" \
+ -p "${PORT}:5432" \
+ "$IMAGE" >/dev/null; then
+ echo "error: failed to start Postgres on localhost:${PORT} (is the port already in use?)" >&2
+ exit 1
+fi
+STARTED_CONTAINER=1
+
+deadline=$((SECONDS + WAIT_SECONDS))
+until docker exec "$CONTAINER" pg_isready -U "$PGUSER" -d "$PGDATABASE" >/dev/null 2>&1; do
+ if (( SECONDS >= deadline )); then
+ echo "error: Postgres did not become ready within ${WAIT_SECONDS}s" >&2
+ docker logs "$CONTAINER" >&2 || true
+ exit 1
+ fi
+ sleep 0.5
+done
+
+export SESSION_STORE_TEST_PG_URL="$URL"
+echo "Postgres ready. Running store tests (${URL})..."
+pnpm --dir packages/server test:store "$@"